Skip to content

Commit 1d753c8

Browse files
authored
Merge pull request #35255 from nextcloud/backport/35218/stable25
[stable25] delay updating setup providers untill we register the mounts
2 parents 0467731 + 326eba8 commit 1d753c8

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

lib/private/Files/SetupManager.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
use OCP\Constants;
4141
use OCP\Diagnostics\IEventLogger;
4242
use OCP\EventDispatcher\IEventDispatcher;
43+
use OCP\Files\Config\ICachedMountInfo;
4344
use OCP\Files\Config\IHomeMountProvider;
4445
use OCP\Files\Config\IMountProvider;
4546
use OCP\Files\Config\IUserMountCache;
@@ -414,9 +415,9 @@ public function setupForPath(string $path, bool $includeChildren = false): void
414415

415416
$mounts = [];
416417
if (!in_array($cachedMount->getMountProvider(), $setupProviders)) {
417-
$setupProviders[] = $cachedMount->getMountProvider();
418418
$currentProviders[] = $cachedMount->getMountProvider();
419419
if ($cachedMount->getMountProvider()) {
420+
$setupProviders[] = $cachedMount->getMountProvider();
420421
$mounts = $this->mountProviderCollection->getUserMountsForProviderClasses($user, [$cachedMount->getMountProvider()]);
421422
} else {
422423
$this->logger->debug("mount at " . $cachedMount->getMountPoint() . " has no provider set, performing full setup");
@@ -427,16 +428,21 @@ public function setupForPath(string $path, bool $includeChildren = false): void
427428

428429
if ($includeChildren) {
429430
$subCachedMounts = $this->userMountCache->getMountsInPath($user, $path);
430-
foreach ($subCachedMounts as $cachedMount) {
431-
if (!in_array($cachedMount->getMountProvider(), $setupProviders)) {
432-
$setupProviders[] = $cachedMount->getMountProvider();
433-
$currentProviders[] = $cachedMount->getMountProvider();
434-
if ($cachedMount->getMountProvider()) {
431+
432+
$needsFullSetup = array_reduce($subCachedMounts, function (bool $needsFullSetup, ICachedMountInfo $cachedMountInfo) {
433+
return $needsFullSetup || $cachedMountInfo->getMountProvider() === '';
434+
}, false);
435+
436+
if ($needsFullSetup) {
437+
$this->logger->debug("mount has no provider set, performing full setup");
438+
$this->setupForUser($user);
439+
return;
440+
} else {
441+
foreach ($subCachedMounts as $cachedMount) {
442+
if (!in_array($cachedMount->getMountProvider(), $setupProviders)) {
443+
$currentProviders[] = $cachedMount->getMountProvider();
444+
$setupProviders[] = $cachedMount->getMountProvider();
435445
$mounts = array_merge($mounts, $this->mountProviderCollection->getUserMountsForProviderClasses($user, [$cachedMount->getMountProvider()]));
436-
} else {
437-
$this->logger->debug("mount at " . $cachedMount->getMountPoint() . " has no provider set, performing full setup");
438-
$this->setupForUser($user);
439-
return;
440446
}
441447
}
442448
}

0 commit comments

Comments
 (0)