]> source.dussan.org Git - nextcloud-server.git/commitdiff
update cached mounts when only specific providers have been setup
authorRobin Appelman <robin@icewind.nl>
Thu, 10 Mar 2022 14:53:39 +0000 (15:53 +0100)
committerRobin Appelman <robin@icewind.nl>
Thu, 24 Mar 2022 16:01:55 +0000 (17:01 +0100)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Files/Config/UserMountCache.php
lib/private/Files/SetupManager.php
lib/public/Files/Config/IUserMountCache.php

index e5c2baa273547435a2225d79f9282c05cfa412cc..6537d07393e12abe6d8c490922b043ae70b86478 100644 (file)
@@ -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);
index 7336e40af8a86a91be113d7c0c70d7869dd952c8..ace408ecb49f8f66344a54361898041c70b2ef2e 100644 (file)
@@ -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']);
                        });
index e45bea9b5d9734a3517d703998980d3fd7154d46..e1cf87563a22e208e3fb37733569c1b9820e4230 100644 (file)
@@ -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