]> source.dussan.org Git - nextcloud-server.git/commitdiff
only register mounts that are new from providers that are new during a full setup 32040/head
authorRobin Appelman <robin@icewind.nl>
Thu, 21 Apr 2022 10:33:43 +0000 (12:33 +0200)
committerRobin Appelman <robin@icewind.nl>
Thu, 21 Apr 2022 10:53:50 +0000 (12:53 +0200)
this fixes cases where during the (partial) setup of a shared mount a full setup is triggered

Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Files/Config/MountProviderCollection.php
lib/private/Files/SetupManager.php

index 334fce15d9ee0419c49e88f021de3b7c9c508e19..0e08d9d0e83ee9b9a58edef9c0dd24d833204bdf 100644 (file)
@@ -234,4 +234,8 @@ class MountProviderCollection implements IMountProviderCollection, Emitter {
                $this->homeProviders = [];
                $this->rootProviders = [];
        }
+
+       public function getProviders(): array {
+               return $this->providers;
+       }
 }
index e0575ea92a58e1e92900c7b49a41d16ed1d1708e..f44ea7c0ab622c582eaf05c4c6f4e5ff77f88a77 100644 (file)
@@ -202,6 +202,8 @@ class SetupManager {
                        $this->setupUserMountProviders[$user->getUID()] = [];
                }
 
+               $previouslySetupProviders = $this->setupUserMountProviders[$user->getUID()];
+
                $this->setupForUserWith($user, function () use ($user) {
                        $this->mountProviderCollection->addMountForUser($user, $this->mountManager, function (
                                IMountProvider $provider
@@ -209,7 +211,7 @@ class SetupManager {
                                return !in_array(get_class($provider), $this->setupUserMountProviders[$user->getUID()]);
                        });
                });
-               $this->afterUserFullySetup($user);
+               $this->afterUserFullySetup($user, $previouslySetupProviders);
        }
 
        /**
@@ -257,13 +259,20 @@ class SetupManager {
        /**
         * Final housekeeping after a user has been fully setup
         */
-       private function afterUserFullySetup(IUser $user): void {
+       private function afterUserFullySetup(IUser $user, array $previouslySetupProviders): void {
                $userRoot = '/' . $user->getUID() . '/';
                $mounts = $this->mountManager->getAll();
                $mounts = array_filter($mounts, function (IMountPoint $mount) use ($userRoot) {
                        return strpos($mount->getMountPoint(), $userRoot) === 0;
                });
-               $this->userMountCache->registerMounts($user, $mounts);
+               $allProviders = array_map(function (IMountProvider $provider) {
+                       return get_class($provider);
+               }, $this->mountProviderCollection->getProviders());
+               $newProviders = array_diff($allProviders, $previouslySetupProviders);
+               $mounts = array_filter($mounts, function (IMountPoint $mount) use ($previouslySetupProviders) {
+                       return !in_array($mount->getMountProvider(), $previouslySetupProviders);
+               });
+               $this->userMountCache->registerMounts($user, $mounts, $newProviders);
 
                $cacheDuration = $this->config->getSystemValueInt('fs_mount_cache_duration', 5 * 60);
                if ($cacheDuration > 0) {