Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/files/cache/scanner.php10
-rw-r--r--tests/lib/files/cache/watcher.php1
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/files/cache/scanner.php b/lib/files/cache/scanner.php
index ff37c944240..b27b3555c91 100644
--- a/lib/files/cache/scanner.php
+++ b/lib/files/cache/scanner.php
@@ -58,9 +58,10 @@ class Scanner {
* scan a single file and store it in the cache
*
* @param string $file
+ * @param bool $checkExisting check existing folder sizes in the cache instead of always using -1 for folder size
* @return array with metadata of the scanned file
*/
- public function scanFile($file) {
+ public function scanFile($file, $checkExisting = false) {
\OC_Hook::emit('\OC\Files\Cache\Scanner', 'scan_file', array('path' => $file, 'storage' => $this->storageId));
$data = $this->getData($file);
if ($data) {
@@ -73,7 +74,10 @@ class Scanner {
$this->scanFile($parent);
}
}
- $id = $this->cache->put($file, $data);
+ if ($data['size'] === -1 and $cacheData = $this->cache->get($file)) {
+ $data['size'] = $cacheData['size'];
+ }
+ $this->cache->put($file, $data);
}
return $data;
}
@@ -99,7 +103,7 @@ class Scanner {
while ($file = readdir($dh)) {
if (!$this->isIgnoredFile($file)) {
$child = ($path) ? $path . '/' . $file : $file;
- $data = $this->scanFile($child);
+ $data = $this->scanFile($child, $recursive === self::SCAN_SHALLOW);
if ($data) {
if ($data['size'] === -1) {
if ($recursive === self::SCAN_RECURSIVE) {
diff --git a/tests/lib/files/cache/watcher.php b/tests/lib/files/cache/watcher.php
index e8a1689cab0..8ef6ab44d10 100644
--- a/tests/lib/files/cache/watcher.php
+++ b/tests/lib/files/cache/watcher.php
@@ -76,7 +76,6 @@ class Watcher extends \PHPUnit_Framework_TestCase {
$updater->checkUpdate('');
$entry = $cache->get('foo.txt');
- $this->assertEquals(-1, $entry['size']);
$this->assertEquals('httpd/unix-directory', $entry['mimetype']);
$this->assertFalse($cache->inCache('folder'));
$this->assertFalse($cache->inCache('folder/bar.txt'));