From 565d830c1102e139b36a33d75ac4201be382426f Mon Sep 17 00:00:00 2001
From: Robin Appelman <robin@icewind.nl>
Date: Wed, 19 Sep 2018 19:02:15 +0200
Subject: [PATCH] expose storagefactory in server container

Signed-off-by: Robin Appelman <robin@icewind.nl>
---
 lib/private/Files/Filesystem.php |  5 +++--
 lib/private/Server.php           | 13 +++++++++++++
 lib/public/IServerContainer.php  |  6 ++++++
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/lib/private/Files/Filesystem.php b/lib/private/Files/Filesystem.php
index ba9c85deeee..404ea4ed804 100644
--- a/lib/private/Files/Filesystem.php
+++ b/lib/private/Files/Filesystem.php
@@ -65,6 +65,7 @@ use OC\Files\Storage\StorageFactory;
 use OC\Lockdown\Filesystem\NullStorage;
 use OCP\Files\Config\IMountProvider;
 use OCP\Files\NotFoundException;
+use OCP\Files\Storage\IStorageFactory;
 use OCP\ILogger;
 use OCP\IUserManager;
 
@@ -246,11 +247,11 @@ class Filesystem {
 	/**
 	 * Returns the storage factory
 	 *
-	 * @return \OCP\Files\Storage\IStorageFactory
+	 * @return IStorageFactory
 	 */
 	public static function getLoader() {
 		if (!self::$loader) {
-			self::$loader = new StorageFactory();
+			self::$loader = \OC::$server->query(IStorageFactory::class);
 		}
 		return self::$loader;
 	}
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 5ea1b697391..e0bd8084282 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -80,6 +80,7 @@ use OC\Files\Mount\ObjectHomeMountProvider;
 use OC\Files\Node\HookConnector;
 use OC\Files\Node\LazyRoot;
 use OC\Files\Node\Root;
+use OC\Files\Storage\StorageFactory;
 use OC\Files\View;
 use OC\Http\Client\ClientService;
 use OC\IntegrityCheck\Checker;
@@ -135,6 +136,7 @@ use OCP\Federation\ICloudFederationProviderManager;
 use OCP\Federation\ICloudIdManager;
 use OCP\Authentication\LoginCredentials\IStore;
 use OCP\Files\NotFoundException;
+use OCP\Files\Storage\IStorageFactory;
 use OCP\GlobalScale\IConfig;
 use OCP\ICacheFactory;
 use OCP\IDBConnection;
@@ -1174,6 +1176,10 @@ class Server extends ServerContainer implements IServerContainer {
 		});
 		$this->registerAlias(IContactsStore::class, ContactsStore::class);
 
+		$this->registerService(IStorageFactory::class, function() {
+			return new StorageFactory();
+		});
+
 		$this->registerAlias(IDashboardManager::class, Dashboard\DashboardManager::class);
 
 		$this->connectDispatcher();
@@ -2024,4 +2030,11 @@ class Server extends ServerContainer implements IServerContainer {
 	public function getRemoteInstanceFactory() {
 		return $this->query(IInstanceFactory::class);
 	}
+
+	/**
+	 * @return IStorageFactory
+	 */
+	public function getStorageFactory() {
+		return $this->query(IStorageFactory::class);
+	}
 }
diff --git a/lib/public/IServerContainer.php b/lib/public/IServerContainer.php
index 639487660b6..a3e494479b7 100644
--- a/lib/public/IServerContainer.php
+++ b/lib/public/IServerContainer.php
@@ -584,4 +584,10 @@ interface IServerContainer extends IContainer {
 	 * @since 13.0.0
 	 */
 	public function getRemoteInstanceFactory();
+
+	/**
+	 * @return \OCP\Files\Storage\IStorageFactory
+	 * @since 15.0.0
+	 */
+	public function getStorageFactory();
 }
-- 
GitLab