]> source.dussan.org Git - nextcloud-server.git/commitdiff
Do not call wrapStorage if storate with same name added twice
authorVincent Petry <pvince81@owncloud.com>
Wed, 21 Jan 2015 21:27:59 +0000 (22:27 +0100)
committerVincent Petry <pvince81@owncloud.com>
Thu, 22 Jan 2015 15:24:24 +0000 (16:24 +0100)
lib/private/files/filesystem.php
lib/private/files/storage/storagefactory.php
lib/public/files/storage/istoragefactory.php

index f90b2738d03f8651c98a9c5ca9d37743697ca922..0a0c5c3612a0a6e40b5455cfcd9a370806b783fa 100644 (file)
@@ -175,7 +175,10 @@ class Filesystem {
         * @param callable $wrapper
         */
        public static function addStorageWrapper($wrapperName, $wrapper) {
-               self::getLoader()->addStorageWrapper($wrapperName, $wrapper);
+               if (!self::getLoader()->addStorageWrapper($wrapperName, $wrapper)) {
+                       // do not re-wrap if storage with this name already existed
+                       return;
+               }
 
                $mounts = self::getMountManager()->getAll();
                foreach ($mounts as $mount) {
index c9e8d422f9d0ce00403dee87a1f5e0b8599d7d87..9c1c7325b76e025ecaf7c72295ec24e4cb2e9106 100644 (file)
@@ -23,9 +23,15 @@ class StorageFactory implements IStorageFactory {
         *
         * @param string $wrapperName
         * @param callable $callback
+        * @return true if the wrapper was added, false if there was already a wrapper with this
+        * name registered
         */
        public function addStorageWrapper($wrapperName, $callback) {
+               if (isset($this->storageWrappers[$wrapperName])) {
+                       return false;
+               }
                $this->storageWrappers[$wrapperName] = $callback;
+               return true;
        }
 
        /**
index 769d7011de4bb7e033a8a0ab156759b0a8b4147b..48c12e44cdde9d2d1a62eaa939c5e59b39fb2ed5 100644 (file)
@@ -19,6 +19,8 @@ interface IStorageFactory {
         *
         * @param string $wrapperName
         * @param callable $callback
+        * @return true if the wrapper was added, false if there was already a wrapper with this
+        * name registered
         */
        public function addStorageWrapper($wrapperName, $callback);