diff options
author | ringmaster <epithet@gmail.com> | 2014-05-20 12:48:48 -0400 |
---|---|---|
committer | ringmaster <epithet@gmail.com> | 2014-05-27 15:21:35 -0400 |
commit | 3b287f8274ef263d3144410bb6e3bf1a966f9d6d (patch) | |
tree | df9d58b65d9136f33e9eebdab7f6376ceaaa342f /lib/private/files | |
parent | fdf26c5a3f4718fcadc214eb69a91f780ce4045c (diff) | |
download | nextcloud-server-3b287f8274ef263d3144410bb6e3bf1a966f9d6d.tar.gz nextcloud-server-3b287f8274ef263d3144410bb6e3bf1a966f9d6d.zip |
Allow the default behavior to come from the config.
Diffstat (limited to 'lib/private/files')
-rw-r--r-- | lib/private/files/cache/scanner.php | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php index 2790d8581f7..24d406f7cd5 100644 --- a/lib/private/files/cache/scanner.php +++ b/lib/private/files/cache/scanner.php @@ -10,6 +10,7 @@ namespace OC\Files\Cache; use OC\Files\Filesystem; use OC\Hooks\BasicEmitter; +use OCP\Config; /** * Class Scanner @@ -156,12 +157,16 @@ class Scanner extends BasicEmitter { } } if (!empty($newData)) { - $data['fileid'] = $this->cache->put($file, $newData); + $addToCache = Config::getSystemValue('allow_scanner_to_affect_cache', true); + \OC_Hook::emit('Scanner', 'addToCache', array('file' => $file, 'addToCache' => &$addToCache, 'data' => &$newData)); + if($addToCache) { + $data['fileid'] = $this->cache->put($file, $newData); + } $this->emit('\OC\Files\Cache\Scanner', 'postScanFile', array($file, $this->storageId)); \OC_Hook::emit('\OC\Files\Cache\Scanner', 'post_scan_file', array('path' => $file, 'storage' => $this->storageId)); } } else { - $removeFromCache = true; + $removeFromCache = Config::getSystemValue('allow_scanner_to_affect_cache', true); \OC_Hook::emit('Scanner', 'removeFromCache', array('file' => $file, 'removeFromCache' => &$removeFromCache)); if($removeFromCache) { $this->cache->remove($file); @@ -248,7 +253,7 @@ class Scanner extends BasicEmitter { $removedChildren = \array_diff($existingChildren, $newChildren); foreach ($removedChildren as $childName) { $child = ($path) ? $path . '/' . $childName : $childName; - $removeFromCache = true; + $removeFromCache = Config::getSystemValue('allow_scanner_to_affect_cache', true); \OC_Hook::emit('Scanner', 'removeFromCache', array('file' => $child, 'removeFromCache' => &$removeFromCache)); if($removeFromCache) { $this->cache->remove($child); @@ -271,10 +276,11 @@ class Scanner extends BasicEmitter { $size += $childSize; } } - $addToCache = true; - \OC_Hook::emit('Scanner', 'addToCache', array('file' => $path, 'addToCache' => &$addToCache, 'size' => &$size)); + $newData = array('size' => $size); + $addToCache = Config::getSystemValue('allow_scanner_to_affect_cache', true); + \OC_Hook::emit('Scanner', 'addToCache', array('file' => $child, 'addToCache' => &$addToCache, 'data' => &$newData)); if($addToCache) { - $this->cache->put($path, array('size' => $size)); + $this->cache->put($path, $newData); } } $this->emit('\OC\Files\Cache\Scanner', 'postScanFolder', array($path, $this->storageId)); |