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
path: root/lib/files
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2013-07-29 18:22:44 +0400
committerMichael Gapczynski <mtgap@owncloud.com>2013-08-02 17:58:38 +0400
commit8c2575aae2bbb36f34da8f030808c7e772b323e7 (patch)
treec5caee9557a49c1a5ef5dc1c565e65c9cb7c0484 /lib/files
parent502a479eb64f1fba3bdab9d59bb1581b0d56d05e (diff)
Use query to calculate folder size
Diffstat (limited to 'lib/files')
-rw-r--r--lib/files/cache/cache.php23
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php
index f605d72a6b3..bc8b07db1a0 100644
--- a/lib/files/cache/cache.php
+++ b/lib/files/cache/cache.php
@@ -503,19 +503,22 @@ class Cache {
$entry = $this->get($path);
if ($entry && $entry['mimetype'] === 'httpd/unix-directory') {
$id = $entry['fileid'];
- $sql = 'SELECT `size` FROM `*PREFIX*filecache` WHERE `parent` = ? AND `storage` = ?';
+ $sql = 'SELECT SUM(`size`), MIN(`size`) FROM `*PREFIX*filecache` '.
+ 'WHERE `parent` = ? AND `storage` = ?';
$result = \OC_DB::executeAudited($sql, array($id, $this->getNumericStorageId()));
- while ($row = $result->fetchRow()) {
- $size = (int)$row['size'];
- if ($size === -1) {
- $totalSize = -1;
- break;
+ if ($row = $result->fetchRow()) {
+ list($sum, $min) = array_values($row);
+ $sum = (int)$sum;
+ $min = (int)$min;
+ if ($min === -1) {
+ $totalSize = $min;
} else {
- $totalSize += $size;
+ $totalSize = $sum;
}
- }
- if ($entry['size'] !== $totalSize) {
- $this->update($id, array('size' => $totalSize));
+ if ($entry['size'] !== $totalSize) {
+ $this->update($id, array('size' => $totalSize));
+ }
+
}
}
return $totalSize;