mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 08:16:43 -04:00
pass user object during fs init
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
3c413025b7
commit
1cfb740d68
2 changed files with 15 additions and 8 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -338,7 +338,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]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue