diff options
Diffstat (limited to 'lib')
-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]); } |