[Pkg-owncloud-commits] [owncloud] 104/199: Prevent apps from affecting the scanner via hook.

David Prévot taffit at moszumanska.debian.org
Sun Jun 1 18:53:14 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 f79948f519f5532f95fd744b8ba28329cc45b022
Author: ringmaster <epithet at gmail.com>
Date:   Wed May 28 13:20:20 2014 -0400

    Prevent apps from affecting the scanner via hook.
---
 lib/private/files/cache/scanner.php | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php
index e838a8b..d4942d7 100644
--- a/lib/private/files/cache/scanner.php
+++ b/lib/private/files/cache/scanner.php
@@ -138,9 +138,12 @@ class Scanner extends BasicEmitter {
 											$parent = '';
 										}
 										$parentCacheData = $this->cache->get($parent);
-										$this->cache->update($parentCacheData['fileid'], array(
-											'etag' => $this->storage->getETag($parent),
-										));
+										\OC_Hook::emit('Scanner', 'updateCache', array('file' => $file, 'data' => $data));
+										if(Config::getSystemValue('filesystem_check_enable', true)) {
+											$this->cache->update($parentCacheData['fileid'], array(
+												'etag' => $this->storage->getETag($parent),
+											));
+										}
 									}
 								}
 							}
@@ -157,18 +160,16 @@ class Scanner extends BasicEmitter {
 					}
 				}
 				if (!empty($newData)) {
-					$addToCache = Config::getSystemValue('filesystem_check_enable', true);
-					\OC_Hook::emit('Scanner', 'addToCache', array('file' => $file, 'addToCache' => &$addToCache, 'data' => &$newData));
-					if($addToCache) {
+					\OC_Hook::emit('Scanner', 'addToCache', array('file' => $file, 'data' => $newData));
+					if(Config::getSystemValue('filesystem_check_enable', true)) {
 						$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 = Config::getSystemValue('filesystem_check_enable', true);
-				\OC_Hook::emit('Scanner', 'removeFromCache', array('file' => $file, 'removeFromCache' => &$removeFromCache));
-				if($removeFromCache) {
+				\OC_Hook::emit('Scanner', 'removeFromCache', array('file' => $file));
+				if(Config::getSystemValue('filesystem_check_enable', true)) {
 					$this->cache->remove($file);
 				}
 			}
@@ -253,9 +254,8 @@ class Scanner extends BasicEmitter {
 			$removedChildren = \array_diff($existingChildren, $newChildren);
 			foreach ($removedChildren as $childName) {
 				$child = ($path) ? $path . '/' . $childName : $childName;
-				$removeFromCache = Config::getSystemValue('filesystem_check_enable', true);
-				\OC_Hook::emit('Scanner', 'removeFromCache', array('file' => $child, 'removeFromCache' => &$removeFromCache));
-				if($removeFromCache) {
+				\OC_Hook::emit('Scanner', 'removeFromCache', array('file' => $child));
+				if(Config::getSystemValue('filesystem_check_enable', true)) {
 					$this->cache->remove($child);
 				}
 			}
@@ -277,9 +277,8 @@ class Scanner extends BasicEmitter {
 				}
 			}
 			$newData = array('size' => $size);
-			$addToCache = Config::getSystemValue('filesystem_check_enable', true);
-			\OC_Hook::emit('Scanner', 'addToCache', array('file' => $child, 'addToCache' => &$addToCache, 'data' => &$newData));
-			if($addToCache) {
+			\OC_Hook::emit('Scanner', 'addToCache', array('file' => $child, 'data' => $newData));
+			if(Config::getSystemValue('filesystem_check_enable', true)) {
 				$this->cache->put($path, $newData);
 			}
 		}
@@ -308,7 +307,10 @@ class Scanner extends BasicEmitter {
 		$lastPath = null;
 		while (($path = $this->cache->getIncomplete()) !== false && $path !== $lastPath) {
 			$this->scan($path, self::SCAN_RECURSIVE, self::REUSE_ETAG);
-			$this->cache->correctFolderSize($path);
+			\OC_Hook::emit('Scanner', 'correctFolderSize', array('path' => $path));
+			if(Config::getSystemValue('filesystem_check_enable', true)) {
+				$this->cache->correctFolderSize($path);
+			}
 			$lastPath = $path;
 		}
 	}

-- 
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