Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions lib/private/Files/Node/Root.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,17 @@ public function getFirstNodeByIdInPath(int $id, string $path): ?INode {
// scope the cache by user, so we don't return nodes for different users
if ($this->user) {
$cachedPath = $this->pathByIdCache->get($this->user->getUID() . '::' . $id);
if ($cachedPath && str_starts_with($path, $cachedPath)) {
if ($cachedPath && str_starts_with($cachedPath, $path)) {
// getting the node by path is significantly cheaper than finding it by id
$node = $this->get($cachedPath);
// by validating that the cached path still has the requested fileid we can work around the need to invalidate the cached path
// if the cached path is invalid or a different file now we fall back to the uncached logic
if ($node && $node->getId() === $id) {
return $node;
try {
$node = $this->get($cachedPath);
// by validating that the cached path still has the requested fileid we can work around the need to invalidate the cached path
// if the cached path is invalid or a different file now we fall back to the uncached logic
if ($node && $node->getId() === $id) {
return $node;
}
} catch (NotFoundException|NotPermittedException) {
// The file may be moved but the old path still in cache
}
}
}
Expand Down
Loading