]> source.dussan.org Git - nextcloud-server.git/commitdiff
perform full setup if a cached mount doesn't have a provider set
authorRobin Appelman <robin@icewind.nl>
Wed, 16 Mar 2022 17:13:45 +0000 (18:13 +0100)
committerRobin Appelman <robin@icewind.nl>
Thu, 24 Mar 2022 16:03:16 +0000 (17:03 +0100)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Files/SetupManager.php
lib/private/Files/SetupManagerFactory.php

index e83b7448414164a1eaaae1b1a36f5f7dff5101af..6da0bf21f8fe38d2c0963c4f4eab4a4f64c822ac 100644 (file)
@@ -57,6 +57,7 @@ use OCP\IUserManager;
 use OCP\IUserSession;
 use OCP\Lockdown\ILockdownManager;
 use OCP\Share\Events\ShareCreatedEvent;
+use Psr\Log\LoggerInterface;
 
 class SetupManager {
        private bool $rootSetup = false;
@@ -75,6 +76,7 @@ class SetupManager {
        private ILockdownManager $lockdownManager;
        private IUserSession $userSession;
        private ICache $cache;
+       private LoggerInterface $logger;
        private bool $listeningForProviders;
 
        public function __construct(
@@ -86,7 +88,8 @@ class SetupManager {
                IUserMountCache $userMountCache,
                ILockdownManager $lockdownManager,
                IUserSession $userSession,
-               ICacheFactory $cacheFactory
+               ICacheFactory $cacheFactory,
+               LoggerInterface $logger
        ) {
                $this->eventLogger = $eventLogger;
                $this->mountProviderCollection = $mountProviderCollection;
@@ -95,6 +98,7 @@ class SetupManager {
                $this->eventDispatcher = $eventDispatcher;
                $this->userMountCache = $userMountCache;
                $this->lockdownManager = $lockdownManager;
+               $this->logger = $logger;
                $this->userSession = $userSession;
                $this->cache = $cacheFactory->createDistributed('setupmanager::');
                $this->listeningForProviders = false;
@@ -378,7 +382,13 @@ class SetupManager {
                if (!in_array($cachedMount->getMountProvider(), $setupProviders)) {
                        $setupProviders[] = $cachedMount->getMountProvider();
                        $currentProviders[] = $cachedMount->getMountProvider();
-                       $mounts = $this->mountProviderCollection->getMountsFromProvider($user, $cachedMount->getMountProvider());
+                       if ($cachedMount->getMountProvider()) {
+                               $mounts = $this->mountProviderCollection->getMountsFromProvider($user, $cachedMount->getMountProvider());
+                       } else {
+                               $this->logger->debug("mount at " . $cachedMount->getMountPoint() . " has no provider set, performing full setup");
+                               $this->setupForUser($user);
+                               return;
+                       }
                }
 
                if ($includeChildren) {
@@ -387,7 +397,13 @@ class SetupManager {
                                if (!in_array($cachedMount->getMountProvider(), $setupProviders)) {
                                        $setupProviders[] = $cachedMount->getMountProvider();
                                        $currentProviders[] = $cachedMount->getMountProvider();
-                                       $mounts = array_merge($mounts, $this->mountProviderCollection->getMountsFromProvider($user, $cachedMount->getMountProvider()));
+                                       if ($cachedMount->getMountProvider()) {
+                                               $mounts = array_merge($mounts, $this->mountProviderCollection->getMountsFromProvider($user, $cachedMount->getMountProvider()));
+                                       } else {
+                                               $this->logger->debug("mount at " . $cachedMount->getMountPoint() . " has no provider set, performing full setup");
+                                               $this->setupForUser($user);
+                                               return;
+                                       }
                                }
                        }
                }
index 122f82c02e925ad7a9b68f081b09f514912e1bd5..d361d42aad9369faf52241f31117d69fcac6f98e 100644 (file)
@@ -32,6 +32,7 @@ use OCP\ICacheFactory;
 use OCP\IUserManager;
 use OCP\IUserSession;
 use OCP\Lockdown\ILockdownManager;
+use Psr\Log\LoggerInterface;
 
 class SetupManagerFactory {
        private IEventLogger $eventLogger;
@@ -43,6 +44,7 @@ class SetupManagerFactory {
        private IUserSession $userSession;
        private ?SetupManager $setupManager;
        private ICacheFactory $cacheFactory;
+       private LoggerInterface $logger;
 
        public function __construct(
                IEventLogger $eventLogger,
@@ -52,7 +54,8 @@ class SetupManagerFactory {
                IUserMountCache $userMountCache,
                ILockdownManager $lockdownManager,
                IUserSession $userSession,
-               ICacheFactory $cacheFactory
+               ICacheFactory $cacheFactory,
+               LoggerInterface $logger
        ) {
                $this->eventLogger = $eventLogger;
                $this->mountProviderCollection = $mountProviderCollection;
@@ -62,6 +65,7 @@ class SetupManagerFactory {
                $this->lockdownManager = $lockdownManager;
                $this->userSession = $userSession;
                $this->cacheFactory = $cacheFactory;
+               $this->logger = $logger;
                $this->setupManager = null;
        }
 
@@ -76,7 +80,8 @@ class SetupManagerFactory {
                                $this->userMountCache,
                                $this->lockdownManager,
                                $this->userSession,
-                               $this->cacheFactory
+                               $this->cacheFactory,
+                               $this->logger
                        );
                }
                return $this->setupManager;