fix: Proper order for checking path prefix for getting file by id from cache

Signed-off-by: Julius Knorr <jus@bitgrid.net>
This commit is contained in:
Julius Knorr 2025-04-07 20:47:11 +02:00
parent 403c33a640
commit 7fa3f89ef9
No known key found for this signature in database
GPG key ID: 4C614C6ED2CDE6DF

View file

@ -384,7 +384,7 @@ class Root extends Folder implements IRootFolder {
// 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