aboutsummaryrefslogtreecommitdiffstats
path: root/lib/files/cache/scanner.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/files/cache/scanner.php')
-rw-r--r--lib/files/cache/scanner.php17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/files/cache/scanner.php b/lib/files/cache/scanner.php
index bcd6032fcac..597eabecf54 100644
--- a/lib/files/cache/scanner.php
+++ b/lib/files/cache/scanner.php
@@ -75,9 +75,10 @@ class Scanner extends BasicEmitter {
*
* @param string $file
* @param int $reuseExisting
+ * @param bool $parentExistsInCache
* @return array with metadata of the scanned file
*/
- public function scanFile($file, $reuseExisting = 0) {
+ public function scanFile($file, $reuseExisting = 0, $parentExistsInCache = false) {
if (!self::isPartialFile($file)
and !Filesystem::isFileBlacklisted($file)
) {
@@ -85,7 +86,7 @@ class Scanner extends BasicEmitter {
\OC_Hook::emit('\OC\Files\Cache\Scanner', 'scan_file', array('path' => $file, 'storage' => $this->storageId));
$data = $this->getData($file);
if ($data) {
- if ($file) {
+ if ($file and !$parentExistsInCache) {
$parent = dirname($file);
if ($parent === '.' or $parent === '/') {
$parent = '';
@@ -97,7 +98,7 @@ class Scanner extends BasicEmitter {
$newData = $data;
if ($reuseExisting and $cacheData = $this->cache->get($file)) {
// only reuse data if the file hasn't explicitly changed
- if ($data['mtime'] === $cacheData['mtime']) {
+ if (isset($data['mtime']) && isset($cacheData['mtime']) && $data['mtime'] === $cacheData['mtime']) {
if (($reuseExisting & self::REUSE_SIZE) && ($data['size'] === -1)) {
$data['size'] = $cacheData['size'];
}
@@ -108,9 +109,9 @@ class Scanner extends BasicEmitter {
// Only update metadata that has changed
$newData = array_diff($data, $cacheData);
}
- }
- if (!empty($newData)) {
- $this->cache->put($file, $newData);
+ if (!empty($newData)) {
+ $this->cache->put($file, $newData);
+ }
}
return $data;
}
@@ -162,7 +163,7 @@ class Scanner extends BasicEmitter {
$child = ($path) ? $path . '/' . $file : $file;
if (!Filesystem::isIgnoredDir($file)) {
$newChildren[] = $file;
- $data = $this->scanFile($child, $reuse);
+ $data = $this->scanFile($child, $reuse, true);
if ($data) {
if ($data['size'] === -1) {
if ($recursive === self::SCAN_RECURSIVE) {
@@ -183,7 +184,7 @@ class Scanner extends BasicEmitter {
}
\OC_DB::commit();
foreach ($childQueue as $child) {
- $childSize = $this->scanChildren($child, self::SCAN_RECURSIVE);
+ $childSize = $this->scanChildren($child, self::SCAN_RECURSIVE, $reuse);
if ($childSize === -1) {
$size = -1;
} else {