]> source.dussan.org Git - nextcloud-server.git/commitdiff
don't double setup provider when calling `setupForUser` after `setupForPath`
authorRobin Appelman <robin@icewind.nl>
Mon, 14 Mar 2022 14:08:24 +0000 (15:08 +0100)
committerRobin Appelman <robin@icewind.nl>
Thu, 24 Mar 2022 16:03:13 +0000 (17:03 +0100)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Files/Config/MountProviderCollection.php
lib/private/Files/SetupManager.php

index efbb54edba566c4e813b668e9a39e889e529a61e..a3c20bdbfbb0359ad36ed6e34f7789605b43230b 100644 (file)
@@ -104,14 +104,19 @@ class MountProviderCollection implements IMountProviderCollection, Emitter {
                return $this->getMountsForFromProviders($user, $providers);
        }
 
-       public function addMountForUser(IUser $user, IMountManager $mountManager) {
+       public function addMountForUser(IUser $user, IMountManager $mountManager, callable $providerFilter = null) {
                // shared mount provider gets to go last since it needs to know existing files
                // to check for name collisions
                $firstMounts = [];
-               $firstProviders = array_filter($this->providers, function (IMountProvider $provider) {
+               if ($providerFilter) {
+                       $providers = array_filter($this->providers, $providerFilter);
+               } else {
+                       $providers = $this->providers;
+               }
+               $firstProviders = array_filter($providers, function (IMountProvider $provider) {
                        return (get_class($provider) !== 'OCA\Files_Sharing\MountProvider');
                });
-               $lastProviders = array_filter($this->providers, function (IMountProvider $provider) {
+               $lastProviders = array_filter($providers, function (IMountProvider $provider) {
                        return (get_class($provider) === 'OCA\Files_Sharing\MountProvider');
                });
                foreach ($firstProviders as $provider) {
index 7e091da0e01459ca6e3f18ee28b2c00be4476c18..e83b7448414164a1eaaae1b1a36f5f7dff5101af 100644 (file)
@@ -204,8 +204,14 @@ class SetupManager {
                }
                $this->setupUsersComplete[] = $user->getUID();
 
+               if (!isset($this->setupUserMountProviders[$user->getUID()])) {
+                       $this->setupUserMountProviders[$user->getUID()] = [];
+               }
+
                $this->setupForUserWith($user, function () use ($user) {
-                       $this->mountProviderCollection->addMountForUser($user, $this->mountManager);
+                       $this->mountProviderCollection->addMountForUser($user, $this->mountManager, function (IMountProvider $provider) use ($user) {
+                               return !in_array(get_class($provider), $this->setupUserMountProviders[$user->getUID()]);
+                       });
                });
                $this->userFullySetup($user);
        }