]> source.dussan.org Git - nextcloud-server.git/commitdiff
fixed when accessing static filesystem calls before setup
authorRobin Appelman <robin@icewind.nl>
Tue, 8 Mar 2022 16:13:06 +0000 (17:13 +0100)
committerRobin Appelman <robin@icewind.nl>
Thu, 24 Mar 2022 16:01:42 +0000 (17:01 +0100)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Files/Filesystem.php

index 9db9252037ff7eadbd304e9bba599361ee15fa99..20b44e2736aa98fab536310a7436c8a637dac7eb 100644 (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);
        }
 
        /**