Skip to content

Commit

Permalink
fix getNodeForPath caching
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Feb 20, 2024
1 parent da8c1f2 commit 0bf4dc6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/DAV/Tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,21 @@ public function getNodeForPath($path)
return $this->rootNode;
}

$parts = explode('/', $path);
$node = $this->rootNode;

// look for any cached parent and collect the parts below the parent
$parts = [];
$remainingPath = $path;
do {
list($remainingPath, $baseName) = Uri\split($remainingPath);
array_unshift($parts, $baseName);

if (isset($this->cache[$remainingPath])) {
$node = $this->cache[$remainingPath];
break;
}
} while ('' !== $remainingPath);

while (count($parts)) {
if (!($node instanceof ICollection)) {
throw new Exception\NotFound('Could not find node at path: '.$path);
Expand Down

0 comments on commit 0bf4dc6

Please sign in to comment.