]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix storage being passed to cache/watcher and scanner when using storage wrappers
authorRobin Appelman <icewind@owncloud.com>
Thu, 12 Jun 2014 15:23:34 +0000 (17:23 +0200)
committerBjoern Schiessle <schiessle@owncloud.com>
Sat, 14 Jun 2014 08:14:08 +0000 (10:14 +0200)
apps/files_sharing/lib/external/storage.php
apps/files_sharing/lib/sharedstorage.php
lib/private/files/storage/common.php
lib/private/files/storage/home.php
lib/private/files/storage/storage.php
lib/private/files/storage/wrapper/wrapper.php

index e25777d60e349212d7e06cd4542e21f9fdc93d18..7eac7f02c27aa2a2675c9840ac6e389bdc173f47 100644 (file)
@@ -85,8 +85,8 @@ class Storage extends DAV implements ISharedStorage {
                return 'shared::' . md5($this->token . '@' . $this->remote);
        }
 
-       public function getCache($path = '') {
-               if (!isset($this->cache)) {
+       public function getCache($path = '', $storage = null) {
+               if (!$storage) {
                        $this->cache = new Cache($this, $this->remote, $this->remoteUser);
                }
                return $this->cache;
@@ -94,11 +94,15 @@ class Storage extends DAV implements ISharedStorage {
 
        /**
         * @param string $path
+        * @param \OC\Files\Storage\Storage $storage
         * @return \OCA\Files_Sharing\External\Scanner
         */
-       public function getScanner($path = '') {
+       public function getScanner($path = '', $storage = null) {
+               if (!$storage) {
+                       $storage = $this;
+               }
                if (!isset($this->scanner)) {
-                       $this->scanner = new Scanner($this);
+                       $this->scanner = new Scanner($storage);
                }
                return $this->scanner;
        }
index 6760538f510bbfc5d4c4afcbb68eaec7e6321de5..8d5b22dc2834b469a5ded592db59cdca906c4667 100644 (file)
@@ -489,16 +489,25 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
                return $this->filemtime($path) > $time;
        }
 
-       public function getCache($path = '') {
-               return new \OC\Files\Cache\Shared_Cache($this);
+       public function getCache($path = '', $storage = null) {
+               if (!$storage) {
+                       $storage = $this;
+               }
+               return new \OC\Files\Cache\Shared_Cache($storage);
        }
 
-       public function getScanner($path = '') {
-               return new \OC\Files\Cache\Scanner($this);
+       public function getScanner($path = '', $storage = null) {
+               if (!$storage) {
+                       $storage = $this;
+               }
+               return new \OC\Files\Cache\Scanner($storage);
        }
 
-       public function getWatcher($path = '') {
-               return new \OC\Files\Cache\Shared_Watcher($this);
+       public function getWatcher($path = '', $storage = null) {
+               if (!$storage) {
+                       $storage = $this;
+               }
+               return new \OC\Files\Cache\Shared_Watcher($storage);
        }
 
        public function getOwner($path) {
index 4d5a2078ef7809d9ebd24eab0f973edbcfaeb61c..ecc75298b66f79555c49bb7a76b0289536058c3b 100644 (file)
@@ -287,31 +287,43 @@ abstract class Common implements \OC\Files\Storage\Storage {
                return $this->filemtime($path) > $time;
        }
 
-       public function getCache($path = '') {
+       public function getCache($path = '', $storage = null) {
+               if (!$storage) {
+                       $storage = $this;
+               }
                if (!isset($this->cache)) {
-                       $this->cache = new \OC\Files\Cache\Cache($this);
+                       $this->cache = new \OC\Files\Cache\Cache($storage);
                }
                return $this->cache;
        }
 
-       public function getScanner($path = '') {
+       public function getScanner($path = '', $storage = null) {
+               if (!$storage) {
+                       $storage = $this;
+               }
                if (!isset($this->scanner)) {
-                       $this->scanner = new \OC\Files\Cache\Scanner($this);
+                       $this->scanner = new \OC\Files\Cache\Scanner($storage);
                }
                return $this->scanner;
        }
 
-       public function getWatcher($path = '') {
+       public function getWatcher($path = '', $storage = null) {
+               if (!$storage) {
+                       $storage = $this;
+               }
                if (!isset($this->watcher)) {
-                       $this->watcher = new \OC\Files\Cache\Watcher($this);
+                       $this->watcher = new \OC\Files\Cache\Watcher($storage);
                        $this->watcher->setPolicy(\OC::$server->getConfig()->getSystemValue('filesystem_check_changes', Watcher::CHECK_ONCE));
                }
                return $this->watcher;
        }
 
-       public function getStorageCache() {
+       public function getStorageCache($storage = null) {
+               if (!$storage) {
+                       $storage = $this;
+               }
                if (!isset($this->storageCache)) {
-                       $this->storageCache = new \OC\Files\Cache\Storage($this);
+                       $this->storageCache = new \OC\Files\Cache\Storage($storage);
                }
                return $this->storageCache;
        }
index f66096f6d9c1660900788afa2433bae3274d7219..214deede620482df85bdea349d2753edb7f6ec3f 100644 (file)
@@ -49,9 +49,12 @@ class Home extends Local {
        /**
         * @return \OC\Files\Cache\HomeCache
         */
-       public function getCache($path = '') {
+       public function getCache($path = '', $storage = null) {
+               if (!$storage) {
+                       $storage = $this;
+               }
                if (!isset($this->cache)) {
-                       $this->cache = new \OC\Files\Cache\HomeCache($this);
+                       $this->cache = new \OC\Files\Cache\HomeCache($storage);
                }
                return $this->cache;
        }
index f085a0590b47d1968dfa813f3080f40793748d8f..2139f464821d349ff2a7bd778dece7f1b0ddfe0a 100644 (file)
@@ -19,17 +19,19 @@ interface Storage extends \OCP\Files\Storage {
         * get a cache instance for the storage
         *
         * @param string $path
+        * @param \OC\Files\Storage\Storage (optional) the storage to pass to the cache
         * @return \OC\Files\Cache\Cache
         */
-       public function getCache($path = '');
+       public function getCache($path = '', $storage = null);
 
        /**
         * get a scanner instance for the storage
         *
         * @param string $path
+        * @param \OC\Files\Storage\Storage (optional) the storage to pass to the scanner
         * @return \OC\Files\Cache\Scanner
         */
-       public function getScanner($path = '');
+       public function getScanner($path = '', $storage = null);
 
 
        /**
@@ -44,9 +46,10 @@ interface Storage extends \OCP\Files\Storage {
         * get a watcher instance for the cache
         *
         * @param string $path
+        * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
         * @return \OC\Files\Cache\Watcher
         */
-       public function getWatcher($path = '');
+       public function getWatcher($path = '', $storage = null);
 
        /**
         * @return \OC\Files\Cache\Storage
index 057c31c3cd84b386692ef0e61201e395717c32fb..d899c88363f20bd387cd171903b3b6aa48d55041 100644 (file)
@@ -361,20 +361,28 @@ class Wrapper implements \OC\Files\Storage\Storage {
         * get a cache instance for the storage
         *
         * @param string $path
+        * @param \OC\Files\Storage\Storage (optional) the storage to pass to the cache
         * @return \OC\Files\Cache\Cache
         */
-       public function getCache($path = '') {
-               return $this->storage->getCache($path);
+       public function getCache($path = '', $storage = null) {
+               if (!$storage) {
+                       $storage = $this;
+               }
+               return $this->storage->getCache($path, $storage);
        }
 
        /**
         * get a scanner instance for the storage
         *
         * @param string $path
+        * @param \OC\Files\Storage\Storage (optional) the storage to pass to the scanner
         * @return \OC\Files\Cache\Scanner
         */
-       public function getScanner($path = '') {
-               return $this->storage->getScanner($path);
+       public function getScanner($path = '', $storage = null) {
+               if (!$storage) {
+                       $storage = $this;
+               }
+               return $this->storage->getScanner($path, $storage);
        }
 
 
@@ -392,10 +400,14 @@ class Wrapper implements \OC\Files\Storage\Storage {
         * get a watcher instance for the cache
         *
         * @param string $path
+        * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
         * @return \OC\Files\Cache\Watcher
         */
-       public function getWatcher($path = '') {
-               return $this->storage->getWatcher($path);
+       public function getWatcher($path = '', $storage = null) {
+               if (!$storage) {
+                       $storage = $this;
+               }
+               return $this->storage->getWatcher($path, $storage);
        }
 
        /**
@@ -417,6 +429,7 @@ class Wrapper implements \OC\Files\Storage\Storage {
 
        /**
         * Returns true
+        *
         * @return true
         */
        public function test() {
@@ -425,6 +438,7 @@ class Wrapper implements \OC\Files\Storage\Storage {
 
        /**
         * Returns the wrapped storage's value for isLocal()
+        *
         * @return bool wrapped storage's isLocal() value
         */
        public function isLocal() {