[Pkg-owncloud-commits] [owncloud] 67/199: Allow apps to control via a hook to skip adding/removing a file during filescan

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 645e7035a45e400d02c56e588f6946d20b522731
Author: ringmaster <epithet at gmail.com>
Date:   Thu May 15 22:38:46 2014 -0400

    Allow apps to control via a hook to skip adding/removing a file during filescan
---
 lib/private/files/cache/scanner.php | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php
index b3ab94f..19321da 100644
--- a/lib/private/files/cache/scanner.php
+++ b/lib/private/files/cache/scanner.php
@@ -161,7 +161,11 @@ class Scanner extends BasicEmitter {
 					\OC_Hook::emit('\OC\Files\Cache\Scanner', 'post_scan_file', array('path' => $file, 'storage' => $this->storageId));
 				}
 			} else {
-				$this->cache->remove($file);
+				$removeFromCache = true;
+				\OC_Hook::emit('Scanner', 'removeFromCache', array('file' => $file, 'removeFromCache' => &$removeFromCache));
+				if($removeFromCache) {
+					$this->cache->remove($file);
+				}
 			}
 			return $data;
 		}
@@ -244,7 +248,11 @@ class Scanner extends BasicEmitter {
 			$removedChildren = \array_diff($existingChildren, $newChildren);
 			foreach ($removedChildren as $childName) {
 				$child = ($path) ? $path . '/' . $childName : $childName;
-				$this->cache->remove($child);
+				$addToCache = true;
+				\OC_Hook::emit('Scanner', 'removeFromCache', array('file' => $child, 'removeFromCache' => &$addToCache));
+				if($addToCache) {
+					$this->cache->remove($child);
+				}
 			}
 			\OC_DB::commit();
 			if ($exceptionOccurred){
@@ -263,7 +271,11 @@ class Scanner extends BasicEmitter {
 					$size += $childSize;
 				}
 			}
-			$this->cache->put($path, array('size' => $size));
+			$addToCache = true;
+			\OC_Hook::emit('Scanner', 'addToCache', array('file' => $path, 'addToCache' => &$addToCache, 'size' => &$size));
+			if($addToCache) {
+				$this->cache->put($path, array('size' => $size));
+			}
 		}
 		$this->emit('\OC\Files\Cache\Scanner', 'postScanFolder', array($path, $this->storageId));
 		return $size;

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