Skip to content

Commit e5209d4

Browse files
committed
fix: Catch old cached paths and fetch the new one
Signed-off-by: Julius Knorr <jus@bitgrid.net>
1 parent 49f2228 commit e5209d4

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/private/Files/Node/Root.php

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

0 commit comments

Comments
 (0)