From 38bd234686d206013d1f402c89e310503a65a5a8 Mon Sep 17 00:00:00 2001
From: Robin Appelman <icewind@owncloud.com>
Date: Sun, 2 Jun 2013 22:09:44 +0200
Subject: [PATCH] make sure the filesystem is setup before doing mount
 operations

---
 lib/files/filesystem.php | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php
index 7e0bcfd1a2..d3fddf8c42 100644
--- a/lib/files/filesystem.php
+++ b/lib/files/filesystem.php
@@ -152,6 +152,9 @@ class Filesystem {
 	 * @return string
 	 */
 	static public function getMountPoint($path) {
+		if (!self::$mounts) {
+			\OC_Util::setupFS();
+		}
 		$mount = self::$mounts->find($path);
 		if ($mount) {
 			return $mount->getMountPoint();
@@ -167,6 +170,9 @@ class Filesystem {
 	 * @return string[]
 	 */
 	static public function getMountPoints($path) {
+		if (!self::$mounts) {
+			\OC_Util::setupFS();
+		}
 		$result = array();
 		$mounts = self::$mounts->findIn($path);
 		foreach ($mounts as $mount) {
@@ -182,6 +188,9 @@ class Filesystem {
 	 * @return \OC\Files\Storage\Storage
 	 */
 	public static function getStorage($mountPoint) {
+		if (!self::$mounts) {
+			\OC_Util::setupFS();
+		}
 		$mount = self::$mounts->find($mountPoint);
 		return $mount->getStorage();
 	}
@@ -191,6 +200,9 @@ class Filesystem {
 	 * @return Mount\Mount[]
 	 */
 	public static function getMountByStorageId($id) {
+		if (!self::$mounts) {
+			\OC_Util::setupFS();
+		}
 		return self::$mounts->findByStorageId($id);
 	}
 
@@ -199,6 +211,9 @@ class Filesystem {
 	 * @return Mount\Mount[]
 	 */
 	public static function getMountByNumericId($id) {
+		if (!self::$mounts) {
+			\OC_Util::setupFS();
+		}
 		return self::$mounts->findByNumericId($id);
 	}
 
@@ -209,6 +224,9 @@ class Filesystem {
 	 * @return array consisting of the storage and the internal path
 	 */
 	static public function resolvePath($path) {
+		if (!self::$mounts) {
+			\OC_Util::setupFS();
+		}
 		$mount = self::$mounts->find($path);
 		if ($mount) {
 			return array($mount->getStorage(), $mount->getInternalPath($path));
@@ -223,7 +241,7 @@ class Filesystem {
 		}
 		self::$defaultInstance = new View($root);
 
-		if(!self::$mounts) {
+		if (!self::$mounts) {
 			self::$mounts = new Mount\Manager();
 		}
 
@@ -235,8 +253,8 @@ class Filesystem {
 		return true;
 	}
 
-	static public function initMounts(){
-		if(!self::$mounts) {
+	static public function initMounts() {
+		if (!self::$mounts) {
 			self::$mounts = new Mount\Manager();
 		}
 	}
@@ -372,6 +390,9 @@ class Filesystem {
 	 * @param string $mountpoint
 	 */
 	static public function mount($class, $arguments, $mountpoint) {
+		if (!self::$mounts) {
+			\OC_Util::setupFS();
+		}
 		$mount = new Mount\Mount($class, $mountpoint, $arguments);
 		self::$mounts->addMount($mount);
 	}
-- 
GitLab