diff options
author | Robin Appelman <robin@icewind.nl> | 2017-04-21 17:11:26 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2017-04-21 17:11:26 +0200 |
commit | 6fbe991afbb5df36c2fef5cac8c9681f91aed311 (patch) | |
tree | 6e47ce18420537a2a146c53cf46ea344e26c4564 /lib/private/Files/Config | |
parent | 140580f9d8468b8450f31dca997916a07693277f (diff) | |
download | nextcloud-server-6fbe991afbb5df36c2fef5cac8c9681f91aed311.tar.gz nextcloud-server-6fbe991afbb5df36c2fef5cac8c9681f91aed311.zip |
limit the user when searching for a file by id if we know the user already
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Files/Config')
-rw-r--r-- | lib/private/Files/Config/UserMountCache.php | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/private/Files/Config/UserMountCache.php b/lib/private/Files/Config/UserMountCache.php index 423eb5c423d..5cbdfaa9d82 100644 --- a/lib/private/Files/Config/UserMountCache.php +++ b/lib/private/Files/Config/UserMountCache.php @@ -220,15 +220,20 @@ class UserMountCache implements IUserMountCache { /** * @param int $numericStorageId + * @param string|null $user limit the results to a single user * @return CachedMountInfo[] */ - public function getMountsForStorageId($numericStorageId) { + public function getMountsForStorageId($numericStorageId, $user = null) { $builder = $this->connection->getQueryBuilder(); $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path') ->from('mounts', 'm') ->innerJoin('m', 'filecache', 'f' , $builder->expr()->eq('m.root_id', 'f.fileid')) ->where($builder->expr()->eq('storage_id', $builder->createPositionalParameter($numericStorageId, IQueryBuilder::PARAM_INT))); + if ($user) { + $query->andWhere($builder->expr()->eq('user_id', $builder->createPositionalParameter($user))); + } + $rows = $query->execute()->fetchAll(); return array_filter(array_map([$this, 'dbRowToMountInfo'], $rows)); @@ -278,16 +283,17 @@ class UserMountCache implements IUserMountCache { /** * @param int $fileId + * @param string|null $user optionally restrict the results to a single user * @return ICachedMountInfo[] * @since 9.0.0 */ - public function getMountsForFileId($fileId) { + public function getMountsForFileId($fileId, $user = null) { try { list($storageId, $internalPath) = $this->getCacheInfoFromFileId($fileId); } catch (NotFoundException $e) { return []; } - $mountsForStorage = $this->getMountsForStorageId($storageId); + $mountsForStorage = $this->getMountsForStorageId($storageId, $user); // filter mounts that are from the same storage but a different directory return array_filter($mountsForStorage, function (ICachedMountInfo $mount) use ($internalPath, $fileId) { |