diff options
author | Robin Appelman <robin@icewind.nl> | 2024-02-07 14:45:47 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2024-03-06 10:54:00 +0100 |
commit | e33b32095ea32177219eb863fe91f62b601f4324 (patch) | |
tree | b040a0e4c0f98ac14ec5875bdbfa119421b49cdf | |
parent | 9ea3f4ab8f79ca7e85376e25540b77d3ca56f97c (diff) | |
download | nextcloud-server-e33b32095ea32177219eb863fe91f62b601f4324.tar.gz nextcloud-server-e33b32095ea32177219eb863fe91f62b601f4324.zip |
Revert "Filter mounts for file id before trying to get user information"
This reverts commit 1e2cf820c89b774d0a8d6f85bfd8d2fd1b4ab2d6.
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r-- | lib/private/Files/Config/UserMountCache.php | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/lib/private/Files/Config/UserMountCache.php b/lib/private/Files/Config/UserMountCache.php index 19fc1a2b573..6c64dc4973f 100644 --- a/lib/private/Files/Config/UserMountCache.php +++ b/lib/private/Files/Config/UserMountCache.php @@ -368,30 +368,18 @@ class UserMountCache implements IUserMountCache { } catch (NotFoundException $e) { return []; } - $builder = $this->connection->getQueryBuilder(); - $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path', 'mount_provider_class') - ->from('mounts', 'm') - ->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid')) - ->where($builder->expr()->eq('storage_id', $builder->createPositionalParameter($storageId, IQueryBuilder::PARAM_INT))); + $mountsForStorage = $this->getMountsForStorageId($storageId, $user); - if ($user) { - $query->andWhere($builder->expr()->eq('user_id', $builder->createPositionalParameter($user))); - } - - $result = $query->execute(); - $rows = $result->fetchAll(); - $result->closeCursor(); // filter mounts that are from the same storage but a different directory - $filteredMounts = array_filter($rows, function (array $row) use ($internalPath, $fileId) { - if ($fileId === (int)$row['root_id']) { + $filteredMounts = array_filter($mountsForStorage, function (ICachedMountInfo $mount) use ($internalPath, $fileId) { + if ($fileId === $mount->getRootId()) { return true; } - $internalMountPath = $row['path'] ?? ''; + $internalMountPath = $mount->getRootInternalPath(); return $internalMountPath === '' || substr($internalPath, 0, strlen($internalMountPath) + 1) === $internalMountPath . '/'; }); - $filteredMounts = array_filter(array_map([$this, 'dbRowToMountInfo'], $filteredMounts)); return array_map(function (ICachedMountInfo $mount) use ($internalPath) { return new CachedMountFileInfo( $mount->getUser(), |