Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1738 from nextcloud/backport/1737/stable28
[stable28] fix(DAV): fix getNodeForPath cache
- Loading branch information
Showing
6 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
diff --git a/lib/DAV/Tree.php b/lib/DAV/Tree.php | ||
index 65b4583ceb..1483e1bc51 100644 | ||
--- a/lib/DAV/Tree.php | ||
+++ b/lib/DAV/Tree.php | ||
@@ -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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
{ | ||
"patches": { | ||
"sabre/dav": { | ||
"Fix getNodeForPath cache": ".patches/fix-cache-for-node.diff" | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
This file was automatically generated by Composer Patches (https://github.com/cweagans/composer-patches) | ||
Patches applied to this directory: | ||
|
||
Fix getNodeForPath cache | ||
Source: .patches/fix-cache-for-node.diff | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters