From 26d169b27c43d06db1158990e33939b85d14a60d Mon Sep 17 00:00:00 2001 From: ringmaster Date: Tue, 27 May 2014 16:01:16 -0400 Subject: Use 'filesystem_check_enable' as a config option. --- config/config.sample.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'config/config.sample.php') diff --git a/config/config.sample.php b/config/config.sample.php index 80694837edc..8fb782e7cf4 100755 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -291,6 +291,9 @@ $CONFIG = array( * 1 -> check each file or folder at most once per request, recomended for general use if outside changes might happen * 2 -> check every time the filesystem is used, causes a performance hit when using external storages, not recomended for regular use */ -'filesystem_check_changes' => 1 +'filesystem_check_changes' => 1, + +/* specifies whether changes in the filesystem outside of owncloud affect cached data about those files */ +'filesystem_check_enable' => 1, ); -- cgit v1.2.3 From 16ae63bdfd8556dceb251fd284dc97d330ca8092 Mon Sep 17 00:00:00 2001 From: ringmaster Date: Fri, 30 May 2014 09:42:41 -0400 Subject: Updates per comments on PR: * Use "filesystem_cache_readonly" config setting, update comment in config.sample * Use $this->cacheActive to cache config setting * Add public Scanner::setCacheActive() to set $cacheActive programmatically --- config/config.sample.php | 4 ++-- lib/private/files/cache/scanner.php | 26 ++++++++++++++++++++------ 2 files changed, 22 insertions(+), 8 deletions(-) (limited to 'config/config.sample.php') diff --git a/config/config.sample.php b/config/config.sample.php index 8fb782e7cf4..e2b4c9b31ab 100755 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -293,7 +293,7 @@ $CONFIG = array( */ 'filesystem_check_changes' => 1, -/* specifies whether changes in the filesystem outside of owncloud affect cached data about those files */ -'filesystem_check_enable' => 1, +/* If true, prevent owncloud from changing the cache due to changes in the filesystem for all storage */ +'filesystem_cache_readonly' => false, ); diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php index d4942d7dc2e..875d941fb77 100644 --- a/lib/private/files/cache/scanner.php +++ b/lib/private/files/cache/scanner.php @@ -44,6 +44,11 @@ class Scanner extends BasicEmitter { */ private $permissionsCache; + /** + * @var boolean $cacheActive If true, perform cache operations, if false, do not affect cache + */ + protected $cacheActive; + const SCAN_RECURSIVE = true; const SCAN_SHALLOW = false; @@ -55,6 +60,7 @@ class Scanner extends BasicEmitter { $this->storageId = $this->storage->getId(); $this->cache = $storage->getCache(); $this->permissionsCache = $storage->getPermissionsCache(); + $this->cacheActive = !Config::getSystemValue('filesystem_cache_readonly', false); } /** @@ -139,7 +145,7 @@ class Scanner extends BasicEmitter { } $parentCacheData = $this->cache->get($parent); \OC_Hook::emit('Scanner', 'updateCache', array('file' => $file, 'data' => $data)); - if(Config::getSystemValue('filesystem_check_enable', true)) { + if($this->cacheActive) { $this->cache->update($parentCacheData['fileid'], array( 'etag' => $this->storage->getETag($parent), )); @@ -161,7 +167,7 @@ class Scanner extends BasicEmitter { } if (!empty($newData)) { \OC_Hook::emit('Scanner', 'addToCache', array('file' => $file, 'data' => $newData)); - if(Config::getSystemValue('filesystem_check_enable', true)) { + if(!Config::getSystemValue('filesystem_cache_readonly', false)) { $data['fileid'] = $this->cache->put($file, $newData); } $this->emit('\OC\Files\Cache\Scanner', 'postScanFile', array($file, $this->storageId)); @@ -169,7 +175,7 @@ class Scanner extends BasicEmitter { } } else { \OC_Hook::emit('Scanner', 'removeFromCache', array('file' => $file)); - if(Config::getSystemValue('filesystem_check_enable', true)) { + if($this->cacheActive) { $this->cache->remove($file); } } @@ -255,7 +261,7 @@ class Scanner extends BasicEmitter { foreach ($removedChildren as $childName) { $child = ($path) ? $path . '/' . $childName : $childName; \OC_Hook::emit('Scanner', 'removeFromCache', array('file' => $child)); - if(Config::getSystemValue('filesystem_check_enable', true)) { + if($this->cacheActive) { $this->cache->remove($child); } } @@ -278,7 +284,7 @@ class Scanner extends BasicEmitter { } $newData = array('size' => $size); \OC_Hook::emit('Scanner', 'addToCache', array('file' => $child, 'data' => $newData)); - if(Config::getSystemValue('filesystem_check_enable', true)) { + if($this->cacheActive) { $this->cache->put($path, $newData); } } @@ -308,10 +314,18 @@ class Scanner extends BasicEmitter { while (($path = $this->cache->getIncomplete()) !== false && $path !== $lastPath) { $this->scan($path, self::SCAN_RECURSIVE, self::REUSE_ETAG); \OC_Hook::emit('Scanner', 'correctFolderSize', array('path' => $path)); - if(Config::getSystemValue('filesystem_check_enable', true)) { + if($this->cacheActive) { $this->cache->correctFolderSize($path); } $lastPath = $path; } } + + /** + * Set whether the cache is affected by scan operations + * @param boolean $active The active state of the cache + */ + public function setCacheActive($active) { + $this->cacheActive = $active; + } } -- cgit v1.2.3