Skip to content

Commit

Permalink
Fix copyNode for case of file named 0 (#1030)
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis authored and staabm committed Jan 22, 2018
1 parent 4acf420 commit 3e8249f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/DAV/Tree.php
Expand Up @@ -298,7 +298,9 @@ function getMultipleNodes($paths) {
*/
protected function copyNode(INode $source, ICollection $destinationParent, $destinationName = null) {

if (!$destinationName) $destinationName = $source->getName();
if ((string)$destinationName === '') {
$destinationName = $source->getName();
}

if ($source instanceof IFile) {

Expand Down
16 changes: 16 additions & 0 deletions tests/Sabre/DAV/TreeTest.php
Expand Up @@ -24,6 +24,22 @@ function testCopy() {

}

function testCopyFile() {

$tree = new TreeMock();
$tree->copy('hi/file', 'hi/newfile');

$this->assertArrayHasKey('newfile', $tree->getNodeForPath('hi')->newFiles);
}

function testCopyFile0() {

$tree = new TreeMock();
$tree->copy('hi/file', 'hi/0');

$this->assertArrayHasKey('0', $tree->getNodeForPath('hi')->newFiles);
}

function testMove() {

$tree = new TreeMock();
Expand Down

0 comments on commit 3e8249f

Please sign in to comment.