From 561a2071e4115e1a96afac343fef339a03a01c9a Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 21 Apr 2022 12:33:43 +0200 Subject: [PATCH] only register mounts that are new from providers that are new during a full setup this fixes cases where during the (partial) setup of a shared mount a full setup is triggered Signed-off-by: Robin Appelman --- .../Files/Config/MountProviderCollection.php | 4 ++++ lib/private/Files/SetupManager.php | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/private/Files/Config/MountProviderCollection.php b/lib/private/Files/Config/MountProviderCollection.php index 334fce15d9e..0e08d9d0e83 100644 --- a/lib/private/Files/Config/MountProviderCollection.php +++ b/lib/private/Files/Config/MountProviderCollection.php @@ -234,4 +234,8 @@ class MountProviderCollection implements IMountProviderCollection, Emitter { $this->homeProviders = []; $this->rootProviders = []; } + + public function getProviders(): array { + return $this->providers; + } } diff --git a/lib/private/Files/SetupManager.php b/lib/private/Files/SetupManager.php index e0575ea92a5..f44ea7c0ab6 100644 --- a/lib/private/Files/SetupManager.php +++ b/lib/private/Files/SetupManager.php @@ -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) { -- 2.39.5