use OCP\Files\Storage\IStorageFactory;
use OCP\IUser;
use OCP\IUserManager;
+use OCP\IUserSession;
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;
}
self::$mounts = \OC::$server->getMountManager();
}
- //load custom mount config
- self::initMountPoints($user);
-
self::$loaded = true;
return true;
* @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;
}
* @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);
}
/**