summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-02-10 18:24:24 +0100
committerRobin Appelman <icewind@owncloud.com>2013-02-11 13:33:41 +0100
commit299649b40e1a87eee7bcead74b269fe8c452e04d (patch)
tree548f997dee774bbb11732167d7cfe5ea0f3d0086 /lib
parent56d10e9054c5f2699e3e0df00bd71a40f53be738 (diff)
downloadnextcloud-server-299649b40e1a87eee7bcead74b269fe8c452e04d.tar.gz
nextcloud-server-299649b40e1a87eee7bcead74b269fe8c452e04d.zip
Cache: reuse known folder sizes when doing a shallow scan
Diffstat (limited to 'lib')
-rw-r--r--lib/files/cache/scanner.php10
1 files changed, 7 insertions, 3 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) {