Skip to content

Commit d38a431

Browse files
juliusknorrbackportbot[bot]
authored andcommitted
fix: Catch old cached paths and fetch the new one
Signed-off-by: Julius Knorr <jus@bitgrid.net>
1 parent af1112d commit d38a431

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

lib/private/Files/Node/Root.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,15 @@ public function getFirstNodeByIdInPath(int $id, string $path): ?INode {
391391
$cachedPath = $this->pathByIdCache->get($this->user->getUID() . '::' . $id);
392392
if ($cachedPath && str_starts_with($cachedPath, $path)) {
393393
// getting the node by path is significantly cheaper than finding it by id
394-
$node = $this->get($cachedPath);
395-
// by validating that the cached path still has the requested fileid we can work around the need to invalidate the cached path
396-
// if the cached path is invalid or a different file now we fall back to the uncached logic
397-
if ($node && $node->getId() === $id) {
398-
return $node;
394+
try {
395+
$node = $this->get($cachedPath);
396+
// by validating that the cached path still has the requested fileid we can work around the need to invalidate the cached path
397+
// if the cached path is invalid or a different file now we fall back to the uncached logic
398+
if ($node && $node->getId() === $id) {
399+
return $node;
400+
}
401+
} catch (NotFoundException|NotPermittedException) {
402+
// The file may be moved but the old path still in cache
399403
}
400404
}
401405
}

0 commit comments

Comments
 (0)