diff options
author | Robin Appelman <robin@icewind.nl> | 2022-03-10 15:53:39 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2022-03-24 17:01:55 +0100 |
commit | 506d29c095e0ff880605bd8e521572ed60c98438 (patch) | |
tree | cc67f8d10595919b972fb4d4423c394bc3466368 /lib | |
parent | a617e1e7115d7ccc01ab846981b17bee828cbcec (diff) | |
download | nextcloud-server-506d29c095e0ff880605bd8e521572ed60c98438.tar.gz nextcloud-server-506d29c095e0ff880605bd8e521572ed60c98438.zip |
update cached mounts when only specific providers have been setup
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Files/Config/UserMountCache.php | 7 | ||||
-rw-r--r-- | lib/private/Files/SetupManager.php | 4 | ||||
-rw-r--r-- | lib/public/Files/Config/IUserMountCache.php | 3 |
3 files changed, 12 insertions, 2 deletions
diff --git a/lib/private/Files/Config/UserMountCache.php b/lib/private/Files/Config/UserMountCache.php index e5c2baa2735..6537d07393e 100644 --- a/lib/private/Files/Config/UserMountCache.php +++ b/lib/private/Files/Config/UserMountCache.php @@ -89,7 +89,7 @@ class UserMountCache implements IUserMountCache { $this->mountsForUsers = new CappedMemoryCache(); } - public function registerMounts(IUser $user, array $mounts) { + public function registerMounts(IUser $user, array $mounts, array $mountProviderClasses = null) { // filter out non-proper storages coming from unit tests $mounts = array_filter($mounts, function (IMountPoint $mount) { return $mount instanceof SharedMount || $mount->getStorage() && $mount->getStorage()->getCache(); @@ -110,6 +110,11 @@ class UserMountCache implements IUserMountCache { $newMounts = array_combine($newMountRootIds, $newMounts); $cachedMounts = $this->getMountsForUser($user); + if (is_array($mountProviderClasses)) { + $cachedMounts = array_filter($cachedMounts, function (ICachedMountInfo $mountInfo) use ($mountProviderClasses) { + return in_array($mountInfo->getMountProvider(), $mountProviderClasses); + }); + } $cachedMountRootIds = array_map(function (ICachedMountInfo $mount) { return $mount->getRootId(); }, $cachedMounts); diff --git a/lib/private/Files/SetupManager.php b/lib/private/Files/SetupManager.php index 7336e40af8a..ace408ecb49 100644 --- a/lib/private/Files/SetupManager.php +++ b/lib/private/Files/SetupManager.php @@ -323,6 +323,7 @@ class SetupManager { $this->setupUserMountProviders[$user->getUID()] = []; } $setupProviders = &$this->setupUserMountProviders[$user->getUID()]; + $currentProviders = []; try { $cachedMount = $this->userMountCache->getMountForPath($user, $path); @@ -334,6 +335,7 @@ class SetupManager { $mounts = []; if (!in_array($cachedMount->getMountProvider(), $setupProviders)) { $setupProviders[] = $cachedMount->getMountProvider(); + $currentProviders[] = $cachedMount->getMountProvider(); $mounts = $this->mountProviderCollection->getMountsFromProvider($user, $cachedMount->getMountProvider()); } @@ -342,12 +344,14 @@ class SetupManager { foreach ($subCachedMounts as $cachedMount) { if (!in_array($cachedMount->getMountProvider(), $setupProviders)) { $setupProviders[] = $cachedMount->getMountProvider(); + $currentProviders[] = $cachedMount->getMountProvider(); $mounts = array_merge($mounts, $this->mountProviderCollection->getMountsFromProvider($user, $cachedMount->getMountProvider())); } } } if (count($mounts)) { + $this->userMountCache->registerMounts($user, $mounts, $currentProviders); $this->setupForUserWith($user, function () use ($mounts) { array_walk($mounts, [$this->mountManager, 'addMount']); }); diff --git a/lib/public/Files/Config/IUserMountCache.php b/lib/public/Files/Config/IUserMountCache.php index e45bea9b5d9..e1cf87563a2 100644 --- a/lib/public/Files/Config/IUserMountCache.php +++ b/lib/public/Files/Config/IUserMountCache.php @@ -39,9 +39,10 @@ interface IUserMountCache { * * @param IUser $user * @param IMountPoint[] $mounts + * @param array|null $mountProviderClasses * @since 9.0.0 */ - public function registerMounts(IUser $user, array $mounts); + public function registerMounts(IUser $user, array $mounts, array $mountProviderClasses = null); /** * Get all cached mounts for a user |