summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-01-14 07:20:16 -0800
committerVincent Petry <pvince81@owncloud.com>2014-01-14 07:20:16 -0800
commitc3a0b0d7f3564ff7a8b80b5b375ea10f31282b8a (patch)
treef5d11a6bda2b9be768b721d1ed29db8cb61ead87 /lib
parentab21c25e386b27f6dd1d21f7c84d183a97c202be (diff)
parent4faba49f0a38427e96ef8393900f799c5a5ba6aa (diff)
downloadnextcloud-server-c3a0b0d7f3564ff7a8b80b5b375ea10f31282b8a.tar.gz
nextcloud-server-c3a0b0d7f3564ff7a8b80b5b375ea10f31282b8a.zip
Merge pull request #6704 from owncloud/encryptedfoldersizecalc
Fix calculated folder size to use unencrypted size
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;