fixed when accessing static filesystem calls before setup

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2022-03-08 17:13:06 +01:00
parent 469a684d45
commit 55d943fd4b
No known key found for this signature in database
GPG key ID: 42B69D8A64526EFB

View file

@ -46,6 +46,7 @@ use OCP\Files\NotFoundException;
use OCP\Files\Storage\IStorageFactory;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
class Filesystem {
@ -321,6 +322,18 @@ class Filesystem {
}
public static function init($user, $root) {
if (self::$defaultInstance) {
return false;
}
self::initInternal($root);
//load custom mount config
self::initMountPoints($user);
return true;
}
public static function initInternal($root) {
if (self::$defaultInstance) {
return false;
}
@ -338,9 +351,6 @@ class Filesystem {
self::$mounts = \OC::$server->getMountManager();
}
//load custom mount config
self::initMountPoints($user);
self::$loaded = true;
return true;
@ -378,6 +388,15 @@ class Filesystem {
* @return View
*/
public static function getView() {
if (!self::$defaultInstance) {
/** @var IUserSession $session */
$session = \OC::$server->get(IUserSession::class);
$user = $session->getUser();
if ($user) {
$userDir = '/' . $user->getUID() . '/files';
self::initInternal($userDir);
}
}
return self::$defaultInstance;
}
@ -736,7 +755,7 @@ class Filesystem {
* @return \OC\Files\FileInfo|false False if file does not exist
*/
public static function getFileInfo($path, $includeMountPoints = true) {
return self::$defaultInstance->getFileInfo($path, $includeMountPoints);
return self::getView()->getFileInfo($path, $includeMountPoints);
}
/**