diff options
author | ringmaster <epithet@gmail.com> | 2014-05-28 13:20:20 -0400 |
---|---|---|
committer | ringmaster <epithet@gmail.com> | 2014-05-28 13:20:20 -0400 |
commit | f79948f519f5532f95fd744b8ba28329cc45b022 (patch) | |
tree | ad69c8bffec25fdf6230736fffbbdf5fd30ab17f /lib | |
parent | 26d169b27c43d06db1158990e33939b85d14a60d (diff) | |
download | nextcloud-server-f79948f519f5532f95fd744b8ba28329cc45b022.tar.gz nextcloud-server-f79948f519f5532f95fd744b8ba28329cc45b022.zip |
Prevent apps from affecting the scanner via hook.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/files/cache/scanner.php | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php index e838a8b6258..d4942d7dc2e 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; } } |