summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-03-10 09:38:24 +0100
committerVincent Petry <pvince81@owncloud.com>2014-03-10 09:38:24 +0100
commit26513bc17b1119060819e391c3faf2a391769f70 (patch)
treeb54e65ff4c86b315a3ab685a17293e9504d99337 /lib
parent212699e389e12e8f9fa7f30992b9b799c11c0299 (diff)
parent48d63a6278078d164774fd182f03ebba5e3c77ad (diff)
downloadnextcloud-server-26513bc17b1119060819e391c3faf2a391769f70.tar.gz
nextcloud-server-26513bc17b1119060819e391c3faf2a391769f70.zip
Merge pull request #7624 from owncloud/enc-encryptedusedspacefix
[master] Fixed used space to be based on unencrypted size
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/cache/homecache.php9
-rw-r--r--lib/private/files/storage/wrapper/quota.php5
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/private/files/cache/homecache.php b/lib/private/files/cache/homecache.php
index a7c310a3782..2af5b03c6e1 100644
--- a/lib/private/files/cache/homecache.php
+++ b/lib/private/files/cache/homecache.php
@@ -24,15 +24,20 @@ class HomeCache extends Cache {
$entry = $this->get($path);
if ($entry && $entry['mimetype'] === 'httpd/unix-directory') {
$id = $entry['fileid'];
- $sql = 'SELECT SUM(`size`) FROM `*PREFIX*filecache` ' .
+ $sql = 'SELECT SUM(`size`) AS f1, ' .
+ 'SUM(`unencrypted_size`) AS f2 FROM `*PREFIX*filecache` ' .
'WHERE `parent` = ? AND `storage` = ? AND `size` >= 0';
$result = \OC_DB::executeAudited($sql, array($id, $this->getNumericStorageId()));
if ($row = $result->fetchRow()) {
- list($sum) = array_values($row);
+ list($sum, $unencryptedSum) = array_values($row);
$totalSize = (int)$sum;
+ $unencryptedSize = (int)$unencryptedSum;
if ($entry['size'] !== $totalSize) {
$this->update($id, array('size' => $totalSize));
}
+ if ($entry['unencrypted_size'] !== $unencryptedSize) {
+ $this->update($id, array('unencrypted_size' => $unencryptedSize));
+ }
}
}
return $totalSize;
diff --git a/lib/private/files/storage/wrapper/quota.php b/lib/private/files/storage/wrapper/quota.php
index 26c952e694a..ea612735477 100644
--- a/lib/private/files/storage/wrapper/quota.php
+++ b/lib/private/files/storage/wrapper/quota.php
@@ -36,6 +36,11 @@ class Quota extends Wrapper {
$cache = $this->getCache();
$data = $cache->get($path);
if (is_array($data) and isset($data['size'])) {
+ if (isset($data['unencrypted_size'])
+ && $data['unencrypted_size'] > 0
+ ) {
+ return $data['unencrypted_size'];
+ }
return $data['size'];
} else {
return \OC\Files\SPACE_NOT_COMPUTED;