Skip to content

Commit

Permalink
clearify logic around getMountsForFileId filtering
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Feb 9, 2024
1 parent 36661a2 commit 5125c00
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/private/Files/Config/UserMountCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,14 +370,14 @@ public function getMountsForFileId($fileId, $user = null) {
}
$mountsForStorage = $this->getMountsForStorageId($storageId, $user);

// filter mounts that are from the same storage but a different directory
// filter mounts that are from the same storage but not a parent of the file we care about
$filteredMounts = array_filter($mountsForStorage, function (ICachedMountInfo $mount) use ($internalPath, $fileId) {
if ($fileId === $mount->getRootId()) {
return true;
}
$internalMountPath = $mount->getRootInternalPath();

return $internalMountPath === '' || substr($internalPath, 0, strlen($internalMountPath) + 1) === $internalMountPath . '/';
return $internalMountPath === '' || str_starts_with($internalPath, $internalMountPath . '/');
});

return array_map(function (ICachedMountInfo $mount) use ($internalPath) {
Expand Down

0 comments on commit 5125c00

Please sign in to comment.