diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php
index 5fa3428643e43822cedd37805568c77610e3e983..c460159ece356c009f83c175966ea6f14fe320a0 100644
--- a/lib/private/files/filesystem.php
+++ b/lib/private/files/filesystem.php
@@ -175,15 +175,11 @@ class Filesystem {
 	 * @param callable $wrapper
 	 */
 	public static function addStorageWrapper($wrapperName, $wrapper) {
-		if (!self::getLoader()->addStorageWrapper($wrapperName, $wrapper)) {
+		$mounts = self::getMountManager()->getAll();
+		if (!self::getLoader()->addStorageWrapper($wrapperName, $wrapper, $mounts)) {
 			// do not re-wrap if storage with this name already existed
 			return;
 		}
-
-		$mounts = self::getMountManager()->getAll();
-		foreach ($mounts as $mount) {
-			$mount->wrapStorage($wrapper);
-		}
 	}
 
 	/**
@@ -201,7 +197,7 @@ class Filesystem {
 	/**
 	 * Returns the mount manager
 	 *
-	 * @return \OC\Files\Filesystem\Mount\Manager
+	 * @return \OC\Files\Mount\Manager
 	 */
 	public static function getMountManager() {
 		if (!self::$mounts) {
diff --git a/lib/private/files/storage/storagefactory.php b/lib/private/files/storage/storagefactory.php
index 6fa360fa84c04599d601da65a597ced73e27da3e..fa6dea2537c4ce1f4328c0ae7ceed86b3f22ad90 100644
--- a/lib/private/files/storage/storagefactory.php
+++ b/lib/private/files/storage/storagefactory.php
@@ -23,13 +23,20 @@ class StorageFactory implements IStorageFactory {
 	 *
 	 * @param string $wrapperName name of the wrapper
 	 * @param callable $callback callback
+	 * @param \OCP\Files\Mount\IMountPoint[] $existingMounts existing mount points to apply the wrapper to
 	 * @return bool true if the wrapper was added, false if there was already a wrapper with this
 	 * name registered
 	 */
-	public function addStorageWrapper($wrapperName, $callback) {
+	public function addStorageWrapper($wrapperName, $callback, $existingMounts = []) {
 		if (isset($this->storageWrappers[$wrapperName])) {
 			return false;
 		}
+
+		// apply to existing mounts before registering it to prevent applying it double in MountPoint::createStorage
+		foreach ($existingMounts as $mount) {
+			$mount->wrapStorage($callback);
+		}
+
 		$this->storageWrappers[$wrapperName] = $callback;
 		return true;
 	}