aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2024-02-07 14:49:31 +0100
committerRobin Appelman <robin@icewind.nl>2024-03-06 10:54:00 +0100
commit51019fda7a74816ca38962d899e7b641a4d5f88e (patch)
treea260970e974db122859334001a517cadb94fc15b /lib
parente33b32095ea32177219eb863fe91f62b601f4324 (diff)
downloadnextcloud-server-51019fda7a74816ca38962d899e7b641a4d5f88e.tar.gz
nextcloud-server-51019fda7a74816ca38962d899e7b641a4d5f88e.zip
fix: clearify logic around getMountsForFileId filtering
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Config/UserMountCache.php11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/private/Files/Config/UserMountCache.php b/lib/private/Files/Config/UserMountCache.php
index 6c64dc4973f..8275eee7b9f 100644
--- a/lib/private/Files/Config/UserMountCache.php
+++ b/lib/private/Files/Config/UserMountCache.php
@@ -251,6 +251,9 @@ class UserMountCache implements IUserMountCache {
*/
public function getMountsForUser(IUser $user) {
$userUID = $user->getUID();
+ if (!$this->userManager->userExists($userUID)) {
+ return [];
+ }
if (!isset($this->mountsForUsers[$userUID])) {
$builder = $this->connection->getQueryBuilder();
$query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'mount_provider_class')
@@ -370,14 +373,18 @@ class UserMountCache implements IUserMountCache {
}
$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 . '/');
+ });
+
+ $filteredMounts = array_filter($filteredMounts, function (ICachedMountInfo $mount) {
+ return $this->userManager->userExists($mount->getUser()->getUID());
});
return array_map(function (ICachedMountInfo $mount) use ($internalPath) {