diff options
author | Robin Appelman <robin@icewind.nl> | 2022-03-17 17:33:36 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-17 17:33:36 +0000 |
commit | eff0fa0e4b0bcfae3412ef66ac76b64a1c0be7e9 (patch) | |
tree | 73b2c126e9326ef4b33b1ad8e5d1ddf83b35a1ea /lib | |
parent | 2a75c303b5ce01f809866a0afb326663b9f9d125 (diff) | |
parent | 577b1fa85619caa53fa80b64504522965daf337b (diff) | |
download | nextcloud-server-eff0fa0e4b0bcfae3412ef66ac76b64a1c0be7e9.tar.gz nextcloud-server-eff0fa0e4b0bcfae3412ef66ac76b64a1c0be7e9.zip |
Merge pull request #31598 from nextcloud/mount-find-root
setup for current user when finding mounts in the root
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Files/SetupManager.php | 15 | ||||
-rw-r--r-- | lib/private/Files/SetupManagerFactory.php | 17 |
2 files changed, 28 insertions, 4 deletions
diff --git a/lib/private/Files/SetupManager.php b/lib/private/Files/SetupManager.php index f9276ef4171..9726fbef428 100644 --- a/lib/private/Files/SetupManager.php +++ b/lib/private/Files/SetupManager.php @@ -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 { diff --git a/lib/private/Files/SetupManagerFactory.php b/lib/private/Files/SetupManagerFactory.php index 5dd1601570d..56e70d09961 100644 --- a/lib/private/Files/SetupManagerFactory.php +++ b/lib/private/Files/SetupManagerFactory.php @@ -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; } |