diff options
author | Robin Appelman <robin@icewind.nl> | 2016-11-17 11:48:29 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2016-11-17 14:59:31 +0100 |
commit | 30e7c27d860bf67ff37778d00fb812aefa8fefa5 (patch) | |
tree | 8287e7b3b57e603e11ad389d19d5c3a6c1cc7a9d /apps/files_sharing | |
parent | de983e61e3660964154d1c7f447ca8a2055cc2d6 (diff) | |
download | nextcloud-server-30e7c27d860bf67ff37778d00fb812aefa8fefa5.tar.gz nextcloud-server-30e7c27d860bf67ff37778d00fb812aefa8fefa5.zip |
reuse the known rootinfo in the shared cache when possible
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/lib/Cache.php | 29 | ||||
-rw-r--r-- | apps/files_sharing/lib/SharedPropagator.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/lib/SharedStorage.php | 6 |
3 files changed, 35 insertions, 2 deletions
diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php index 6444dbb8a36..21f3ff622f9 100644 --- a/apps/files_sharing/lib/Cache.php +++ b/apps/files_sharing/lib/Cache.php @@ -57,6 +57,8 @@ class Cache extends CacheJail { */ private $sourceCache; + private $rootUnchanged = true; + /** * @param \OCA\Files_Sharing\SharedStorage $storage * @param IStorage $sourceStorage @@ -81,6 +83,33 @@ class Cache extends CacheJail { } } + public function get($file) { + if ($this->rootUnchanged && ($file === '' || $file === $this->sourceRootInfo->getId())) { + return $this->formatCacheEntry(clone $this->sourceRootInfo); + } + return parent::get($file); + } + + public function update($id, array $data) { + $this->rootUnchanged = false; + parent::update($id, $data); + } + + public function insert($file, array $data) { + $this->rootUnchanged = false; + return parent::insert($file, $data); + } + + public function remove($file) { + $this->rootUnchanged = false; + parent::remove($file); + } + + public function moveFromCache(\OCP\Files\Cache\ICache $sourceCache, $sourcePath, $targetPath) { + $this->rootUnchanged = false; + return parent::moveFromCache($sourceCache, $sourcePath, $targetPath); + } + protected function formatCacheEntry($entry) { $path = isset($entry['path']) ? $entry['path'] : ''; $entry = parent::formatCacheEntry($entry); diff --git a/apps/files_sharing/lib/SharedPropagator.php b/apps/files_sharing/lib/SharedPropagator.php index 0273744da11..f35a5b1d22b 100644 --- a/apps/files_sharing/lib/SharedPropagator.php +++ b/apps/files_sharing/lib/SharedPropagator.php @@ -39,6 +39,6 @@ class SharedPropagator extends Propagator { public function propagateChange($internalPath, $time, $sizeDifference = 0) { /** @var \OC\Files\Storage\Storage $storage */ list($storage, $sourceInternalPath) = $this->storage->resolvePath($internalPath); - return $storage->getPropagator()->propagateChange($sourceInternalPath, $time, $sizeDifference); + $storage->getPropagator()->propagateChange($sourceInternalPath, $time, $sizeDifference); } } diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index 8362a759135..7002d388d93 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -311,6 +311,9 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto } public function getCache($path = '', $storage = null) { + if ($this->cache) { + return $this->cache; + } $this->init(); if (is_null($this->storage) || $this->storage instanceof FailedStorage) { return new FailedCache(false); @@ -318,7 +321,8 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto if (!$storage) { $storage = $this; } - return new \OCA\Files_Sharing\Cache($storage, $this->storage, $this->sourceRootInfo); + $this->cache = new \OCA\Files_Sharing\Cache($storage, $this->storage, $this->sourceRootInfo); + return $this->cache; } public function getScanner($path = '', $storage = null) { |