]> source.dussan.org Git - nextcloud-server.git/commitdiff
setup for current user when finding mounts in the root 31598/head
authorRobin Appelman <robin@icewind.nl>
Wed, 16 Mar 2022 17:28:26 +0000 (18:28 +0100)
committerRobin Appelman <robin@icewind.nl>
Thu, 17 Mar 2022 13:56:49 +0000 (14:56 +0100)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Files/SetupManager.php
lib/private/Files/SetupManagerFactory.php

index f9276ef41718be40aa1560894afd1678eeccde73..9726fbef428531bf71121bb91ac51f88f1ce4c61 100644 (file)
@@ -48,6 +48,7 @@ use OCP\Files\Mount\IMountPoint;
 use OCP\Files\Storage\IStorage;
 use OCP\IUser;
 use OCP\IUserManager;
+use OCP\IUserSession;
 use OCP\Lockdown\ILockdownManager;
 
 class SetupManager {
@@ -60,6 +61,7 @@ class SetupManager {
        private IEventDispatcher $eventDispatcher;
        private IUserMountCache $userMountCache;
        private ILockdownManager $lockdownManager;
+       private IUserSession $userSession;
        private bool $listeningForProviders;
 
        public function __construct(
@@ -69,7 +71,8 @@ class SetupManager {
                IUserManager $userManager,
                IEventDispatcher $eventDispatcher,
                IUserMountCache $userMountCache,
-               ILockdownManager $lockdownManager
+               ILockdownManager $lockdownManager,
+               IUserSession $userSession
        ) {
                $this->eventLogger = $eventLogger;
                $this->mountProviderCollection = $mountProviderCollection;
@@ -78,6 +81,7 @@ class SetupManager {
                $this->eventDispatcher = $eventDispatcher;
                $this->userMountCache = $userMountCache;
                $this->lockdownManager = $lockdownManager;
+               $this->userSession = $userSession;
                $this->listeningForProviders = false;
        }
 
@@ -239,7 +243,14 @@ class SetupManager {
         * Set up the filesystem for the specified path
         */
        public function setupForPath(string $path): void {
-               if (substr_count($path, '/') < 2 || strpos($path, '/appdata_' . \OC_Util::getInstanceId()) === 0 || strpos($path, '/files_external/') === 0) {
+               if (substr_count($path, '/') < 2) {
+                       if ($user = $this->userSession->getUser()) {
+                               $this->setupForUser($user);
+                       } else {
+                               $this->setupRoot();
+                       }
+                       return;
+               } elseif (strpos($path, '/appdata_' . \OC_Util::getInstanceId()) === 0 || strpos($path, '/files_external/') === 0) {
                        $this->setupRoot();
                        return;
                } else {
index 5dd1601570d034a64f0fa78e635d16e62aaae7fb..56e70d09961c7347ce87987b984f5da8b7197af4 100644 (file)
@@ -29,6 +29,7 @@ use OCP\Files\Config\IMountProviderCollection;
 use OCP\Files\Config\IUserMountCache;
 use OCP\Files\Mount\IMountManager;
 use OCP\IUserManager;
+use OCP\IUserSession;
 use OCP\Lockdown\ILockdownManager;
 
 class SetupManagerFactory {
@@ -38,6 +39,7 @@ class SetupManagerFactory {
        private IEventDispatcher $eventDispatcher;
        private IUserMountCache $userMountCache;
        private ILockdownManager $lockdownManager;
+       private IUserSession $userSession;
        private ?SetupManager $setupManager;
 
        public function __construct(
@@ -46,7 +48,8 @@ class SetupManagerFactory {
                IUserManager $userManager,
                IEventDispatcher $eventDispatcher,
                IUserMountCache $userMountCache,
-               ILockdownManager $lockdownManager
+               ILockdownManager $lockdownManager,
+               IUserSession $userSession
        ) {
                $this->eventLogger = $eventLogger;
                $this->mountProviderCollection = $mountProviderCollection;
@@ -54,12 +57,22 @@ class SetupManagerFactory {
                $this->eventDispatcher = $eventDispatcher;
                $this->userMountCache = $userMountCache;
                $this->lockdownManager = $lockdownManager;
+               $this->userSession = $userSession;
                $this->setupManager = null;
        }
 
        public function create(IMountManager $mountManager): SetupManager {
                if (!$this->setupManager) {
-                       $this->setupManager = new SetupManager($this->eventLogger, $this->mountProviderCollection, $mountManager, $this->userManager, $this->eventDispatcher, $this->userMountCache, $this->lockdownManager);
+                       $this->setupManager = new SetupManager(
+                               $this->eventLogger,
+                               $this->mountProviderCollection,
+                               $mountManager,
+                               $this->userManager,
+                               $this->eventDispatcher,
+                               $this->userMountCache,
+                               $this->lockdownManager,
+                               $this->userSession,
+                       );
                }
                return $this->setupManager;
        }