]> source.dussan.org Git - nextcloud-server.git/commitdiff
delay updating setup providers untill we register the mounts 35258/head
authorRobin Appelman <robin@icewind.nl>
Wed, 16 Nov 2022 16:47:52 +0000 (17:47 +0100)
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>
Fri, 18 Nov 2022 14:38:30 +0000 (14:38 +0000)
otherwise the fallback to a full setup for a missing cached mount provider will lead to a race condition

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

index 5782a5a72a6ce54497c72e50c9c52e74692fd817..82f3bd25670cbb9b53d86b01bdca1434ff8c7afe 100644 (file)
@@ -40,6 +40,7 @@ use OC_Util;
 use OCP\Constants;
 use OCP\Diagnostics\IEventLogger;
 use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Files\Config\ICachedMountInfo;
 use OCP\Files\Config\IHomeMountProvider;
 use OCP\Files\Config\IMountProvider;
 use OCP\Files\Config\IUserMountCache;
@@ -414,9 +415,9 @@ class SetupManager {
 
                $mounts = [];
                if (!in_array($cachedMount->getMountProvider(), $setupProviders)) {
-                       $setupProviders[] = $cachedMount->getMountProvider();
                        $currentProviders[] = $cachedMount->getMountProvider();
                        if ($cachedMount->getMountProvider()) {
+                               $setupProviders[] = $cachedMount->getMountProvider();
                                $mounts = $this->mountProviderCollection->getUserMountsForProviderClasses($user, [$cachedMount->getMountProvider()]);
                        } else {
                                $this->logger->debug("mount at " . $cachedMount->getMountPoint() . " has no provider set, performing full setup");
@@ -427,16 +428,21 @@ class SetupManager {
 
                if ($includeChildren) {
                        $subCachedMounts = $this->userMountCache->getMountsInPath($user, $path);
-                       foreach ($subCachedMounts as $cachedMount) {
-                               if (!in_array($cachedMount->getMountProvider(), $setupProviders)) {
-                                       $setupProviders[] = $cachedMount->getMountProvider();
-                                       $currentProviders[] = $cachedMount->getMountProvider();
-                                       if ($cachedMount->getMountProvider()) {
+
+                       $needsFullSetup = array_reduce($subCachedMounts, function (bool $needsFullSetup, ICachedMountInfo $cachedMountInfo) {
+                               return $needsFullSetup || $cachedMountInfo->getMountProvider() === '';
+                       }, false);
+
+                       if ($needsFullSetup) {
+                               $this->logger->debug("mount has no provider set, performing full setup");
+                               $this->setupForUser($user);
+                               return;
+                       } else {
+                               foreach ($subCachedMounts as $cachedMount) {
+                                       if (!in_array($cachedMount->getMountProvider(), $setupProviders)) {
+                                               $currentProviders[] = $cachedMount->getMountProvider();
+                                               $setupProviders[] = $cachedMount->getMountProvider();
                                                $mounts = array_merge($mounts, $this->mountProviderCollection->getUserMountsForProviderClasses($user, [$cachedMount->getMountProvider()]));
-                                       } else {
-                                               $this->logger->debug("mount at " . $cachedMount->getMountPoint() . " has no provider set, performing full setup");
-                                               $this->setupForUser($user);
-                                               return;
                                        }
                                }
                        }