diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-11-30 17:29:42 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2016-01-20 16:30:22 +0100 |
commit | f986fb99f21f7d42bc4386b67638201afc339b8f (patch) | |
tree | 4f90a7907dfcc5d6891205fb81b2af8f6ccdd614 /lib/private | |
parent | cf6ee1c866ccca617cb2cae98966f04612084e7f (diff) | |
download | nextcloud-server-f986fb99f21f7d42bc4386b67638201afc339b8f.tar.gz nextcloud-server-f986fb99f21f7d42bc4386b67638201afc339b8f.zip |
Filter uncached mounts
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/files/config/usermountcache.php | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/lib/private/files/config/usermountcache.php b/lib/private/files/config/usermountcache.php index b191926a5a4..af4fe6488d4 100644 --- a/lib/private/files/config/usermountcache.php +++ b/lib/private/files/config/usermountcache.php @@ -55,14 +55,22 @@ class UserMountCache implements IUserMountCache { } public function registerMounts(IUser $user, array $mounts) { + $mounts = array_filter($mounts, function (IMountPoint $mount) { + return $mount->getStorage()->getCache(); + }); $mounts = array_values($mounts); /** @var ICachedMountInfo[] $newMounts */ $newMounts = array_map(function (IMountPoint $mount) use ($user) { $storage = $mount->getStorage(); $rootId = (int)$storage->getCache()->getId(''); $storageId = (int)$storage->getStorageCache()->getNumericId(); - return new CachedMountInfo($user, $storageId, $rootId, $mount->getMountPoint()); + if ($rootId === -1) { + return null; + } else { + return new CachedMountInfo($user, $storageId, $rootId, $mount->getMountPoint()); + } }, $mounts); + $newMounts = array_values(array_filter($newMounts)); $cachedMounts = $this->getMountsForUser($user); $mountDiff = function (ICachedMountInfo $mount1, ICachedMountInfo $mount2) { @@ -122,17 +130,14 @@ class UserMountCache implements IUserMountCache { * @return ICachedMountInfo[] */ public function getMountsForUser(IUser $user) { - if (!isset($this->mountsForUsers[$user->getUID()])) { - $builder = $this->connection->getQueryBuilder(); - $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point') - ->from('mounts') - ->where($builder->expr()->eq('user_id', $builder->createPositionalParameter($user->getUID()))); + $builder = $this->connection->getQueryBuilder(); + $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point') + ->from('mounts') + ->where($builder->expr()->eq('user_id', $builder->createPositionalParameter($user->getUID()))); - $rows = $query->execute()->fetchAll(); + $rows = $query->execute()->fetchAll(); - $this->mountsForUsers[$user->getUID()] = array_map([$this, 'dbRowToMountInfo'], $rows); - } - return $this->mountsForUsers[$user->getUID()]; + return array_map([$this, 'dbRowToMountInfo'], $rows); } /** |