summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-01-09 17:27:55 +0100
committerVincent Petry <pvince81@owncloud.com>2014-01-09 17:47:50 +0100
commit4faba49f0a38427e96ef8393900f799c5a5ba6aa (patch)
tree0c403d3ac7c13f48174d84026ea6e69f40b2ea3b /lib
parentd8b8abb429d3d66598a16d25cf55f7dc19e3f996 (diff)
downloadnextcloud-server-4faba49f0a38427e96ef8393900f799c5a5ba6aa.tar.gz
nextcloud-server-4faba49f0a38427e96ef8393900f799c5a5ba6aa.zip
Fix calculated folder size to use unencrypted size
The encrypted size was used when calculating folder sizes. This fix now also sums up the unencrypted size and shows that one when available.
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/cache/cache.php22
1 files changed, 17 insertions, 5 deletions
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php
index 8e682a96b75..1e7936ca26d 100644
--- a/lib/private/files/cache/cache.php
+++ b/lib/private/files/cache/cache.php
@@ -178,7 +178,7 @@ class Cache {
if ($file['storage_mtime'] == 0) {
$file['storage_mtime'] = $file['mtime'];
}
- if ($file['encrypted']) {
+ if ($file['encrypted'] or ($file['unencrypted_size'] > 0 and $file['mimetype'] === 'httpd/unix-directory')) {
$file['encrypted_size'] = $file['size'];
$file['size'] = $file['unencrypted_size'];
}
@@ -511,22 +511,34 @@ class Cache {
$entry = $this->get($path);
if ($entry && $entry['mimetype'] === 'httpd/unix-directory') {
$id = $entry['fileid'];
- $sql = 'SELECT SUM(`size`) AS f1, MIN(`size`) AS f2 FROM `*PREFIX*filecache` '.
+ $sql = 'SELECT SUM(`size`) AS f1, MIN(`size`) AS f2, ' .
+ 'SUM(`unencrypted_size`) AS f3 ' .
+ 'FROM `*PREFIX*filecache` ' .
'WHERE `parent` = ? AND `storage` = ?';
$result = \OC_DB::executeAudited($sql, array($id, $this->getNumericStorageId()));
if ($row = $result->fetchRow()) {
- list($sum, $min) = array_values($row);
+ list($sum, $min, $unencryptedSum) = array_values($row);
$sum = (int)$sum;
$min = (int)$min;
+ $unencryptedSum = (int)$unencryptedSum;
if ($min === -1) {
$totalSize = $min;
} else {
$totalSize = $sum;
}
+ $update = array();
if ($entry['size'] !== $totalSize) {
- $this->update($id, array('size' => $totalSize));
+ $update['size'] = $totalSize;
+ }
+ if ($entry['unencrypted_size'] !== $unencryptedSum) {
+ $update['unencrypted_size'] = $unencryptedSum;
+ }
+ if (count($update) > 0) {
+ $this->update($id, $update);
+ }
+ if ($totalSize !== -1 and $unencryptedSum > 0) {
+ $totalSize = $unencryptedSum;
}
-
}
}
return $totalSize;