[Pkg-owncloud-commits] [owncloud] 69/199: Allow the default behavior to come from the config.

David Prévot taffit at moszumanska.debian.org
Sun Jun 1 18:53:10 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 3b287f8274ef263d3144410bb6e3bf1a966f9d6d
Author: ringmaster <epithet at gmail.com>
Date:   Tue May 20 12:48:48 2014 -0400

    Allow the default behavior to come from the config.
---
 lib/private/files/cache/scanner.php | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php
index 2790d85..24d406f 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));

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list