Skip to content

Commit

Permalink
pass getNodeForPath requests to sub trees
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed May 25, 2018
1 parent c1ce98f commit 02f6996
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
9 changes: 7 additions & 2 deletions lib/DAV/Tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,13 @@ function getNodeForPath($path) {
if (!($node instanceof ICollection))
throw new Exception\NotFound('Could not find node at path: ' . $path);

$part = array_shift($parts);
if ($part !== '') $node = $node->getChild($part);
if ($node instanceof self) {
$node = $node->getNodeForPath(implode('/', $parts));
break;
} else {
$part = array_shift($parts);
if ($part !== '') $node = $node->getChild($part);
}
}

$this->cache[$path] = $node;
Expand Down
14 changes: 13 additions & 1 deletion tests/Sabre/DAV/TreeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ function testGetMultipleNodes2() {

}

function testGetSubTreeNode() {

$tree = new TreeMock();
$this->assertTrue($tree->nodeExists('subtree/sub/1'));

}

}

class TreeMock extends Tree {
Expand All @@ -119,7 +126,12 @@ function __construct() {
new TreeFileTester('1'),
new TreeFileTester('2'),
new TreeFileTester('3'),
])
]),
new Tree(new TreeDirectoryTester('subtree', [
new TreeDirectoryTester('sub', [
new TreeFileTester('1')
]),
]))
])
);

Expand Down

0 comments on commit 02f6996

Please sign in to comment.