diff options
author | Robin Appelman <robin@icewind.nl> | 2022-02-01 13:49:43 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2022-02-09 16:01:24 +0100 |
commit | 1ab58eff0f0e07aafd97a88647c2c72313506e53 (patch) | |
tree | 11e0c89c343b931edf396b7493995d509d253180 /lib/private | |
parent | 0217949715ecbb45982967523c2b4bf9fb53375b (diff) | |
download | nextcloud-server-1ab58eff0f0e07aafd97a88647c2c72313506e53.tar.gz nextcloud-server-1ab58eff0f0e07aafd97a88647c2c72313506e53.zip |
pass user object during fs init
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Files/Filesystem.php | 21 | ||||
-rw-r--r-- | lib/private/legacy/OC_Util.php | 2 |
2 files changed, 15 insertions, 8 deletions
diff --git a/lib/private/Files/Filesystem.php b/lib/private/Files/Filesystem.php index 980fdef6831..fe55373ef44 100644 --- a/lib/private/Files/Filesystem.php +++ b/lib/private/Files/Filesystem.php @@ -45,6 +45,7 @@ use OCP\Files\Config\IMountProvider; use OCP\Files\NotFoundException; use OCP\Files\Storage\IStorageFactory; use OCP\ILogger; +use OCP\IUser; use OCP\IUserManager; class Filesystem { @@ -353,14 +354,23 @@ class Filesystem { /** * Initialize system and personal mount points for a user * - * @param string $user + * @param string|IUser|null $user * @throws \OC\User\NoUserException if the user is not available */ public static function initMountPoints($user = '') { - if ($user == '') { - $user = \OC_User::getUser(); + $userManager = \OC::$server->getUserManager(); + if (is_string($user)) { + if ($user === '') { + $user = \OC_User::getUser(); + } + + $userObject = $userManager->get($user); + } elseif ($user instanceof IUser) { + $userObject = $user; + $user = $userObject->getUID(); } - if ($user === null || $user === false || $user === '') { + + if ($userObject === null || $user === false || $user === '') { throw new \OC\User\NoUserException('Attempted to initialize mount points for null user and no user in session'); } @@ -370,9 +380,6 @@ class Filesystem { self::$usersSetup[$user] = true; - $userManager = \OC::$server->getUserManager(); - $userObject = $userManager->get($user); - if (is_null($userObject)) { \OCP\Util::writeLog('files', ' Backends provided no user object for ' . $user, ILogger::ERROR); // reset flag, this will make it possible to rethrow the exception if called again diff --git a/lib/private/legacy/OC_Util.php b/lib/private/legacy/OC_Util.php index bf911d3a120..57b36983266 100644 --- a/lib/private/legacy/OC_Util.php +++ b/lib/private/legacy/OC_Util.php @@ -339,7 +339,7 @@ class OC_Util { $userDir = '/' . $userObject->getUID() . '/files'; //jail the user into his "home" directory - \OC\Files\Filesystem::init($userObject->getUID(), $userDir); + \OC\Files\Filesystem::init($userObject, $userDir); OC_Hook::emit('OC_Filesystem', 'setup', ['user' => $userObject->getUID(), 'user_dir' => $userDir]); } |