summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin <martin.mattel@diemattels.at>2016-01-13 21:40:48 +0100
committerMartin <martin.mattel@diemattels.at>2016-01-13 21:40:48 +0100
commit06ca5cbade3f9aa69e49c13276965129d7c9e664 (patch)
tree5985603604dc3608a0ee7518b848c4af25e3f561
parentd0a690fde46d1bba886e0a94a5e59c40f1e5c3b0 (diff)
downloadnextcloud-server-06ca5cbade3f9aa69e49c13276965129d7c9e664.tar.gz
nextcloud-server-06ca5cbade3f9aa69e49c13276965129d7c9e664.zip
Fix: emit 'scanFiles' will only fire on files and not on folders (II)
-rw-r--r--lib/private/files/cache/scanner.php32
1 files changed, 25 insertions, 7 deletions
diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php
index 79f749394f1..d70a1e4d416 100644
--- a/lib/private/files/cache/scanner.php
+++ b/lib/private/files/cache/scanner.php
@@ -133,16 +133,25 @@ class Scanner extends BasicEmitter {
* @throws \OCP\Lock\LockedException
*/
public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) {
- if (!self::isPartialFile($file)
- and !Filesystem::isFileBlacklisted($file)
- ) {
+
+ // only proceed if $file is not a partial file nor a blacklisted file
+ if (!self::isPartialFile($file) and !Filesystem::isFileBlacklisted($file)) {
+
+ //acquire a lock
if ($lock) {
$this->storage->acquireLock($file, ILockingProvider::LOCK_SHARED, $this->lockingProvider);
}
- $this->emit('\OC\Files\Cache\Scanner', 'scanFile', array($file, $this->storageId));
- \OC_Hook::emit('\OC\Files\Cache\Scanner', 'scan_file', array('path' => $file, 'storage' => $this->storageId));
+
$data = $this->getData($file);
+
if ($data) {
+
+ // pre-emit only if it was a file. By that we avoid counting/treating folders as files
+ if ($data['mimetype'] !== 'httpd/unix-directory') {
+ $this->emit('\OC\Files\Cache\Scanner', 'scanFile', array($file, $this->storageId));
+ \OC_Hook::emit('\OC\Files\Cache\Scanner', 'scan_file', array('path' => $file, 'storage' => $this->storageId));
+ }
+
$parent = dirname($file);
if ($parent === '.' or $parent === '/') {
$parent = '';
@@ -190,16 +199,25 @@ class Scanner extends BasicEmitter {
if (!empty($newData)) {
$data['fileid'] = $this->addToCache($file, $newData, $fileId);
}
- $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));
+
+ // post-emit only if it was a file. By that we avoid counting/treating folders as files
+ if ($data['mimetype'] !== 'httpd/unix-directory') {
+ $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 {
$this->removeFromCache($file);
}
+
+ //release the acquired lock
if ($lock) {
$this->storage->releaseLock($file, ILockingProvider::LOCK_SHARED, $this->lockingProvider);
}
+
return $data;
}
+
return null;
}