mirror of
https://github.com/nextcloud/server.git
synced 2026-02-23 01:40:59 -05:00
fix: Catch old cached paths and fetch the new one
Signed-off-by: Julius Knorr <jus@bitgrid.net>
This commit is contained in:
parent
af1112dac3
commit
d38a431030
1 changed files with 9 additions and 5 deletions
|
|
@ -391,11 +391,15 @@ class Root extends Folder implements IRootFolder {
|
|||
$cachedPath = $this->pathByIdCache->get($this->user->getUID() . '::' . $id);
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue