summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-03-07 11:25:29 +0100
committerVincent Petry <pvince81@owncloud.com>2014-03-07 14:59:09 +0100
commit48d63a6278078d164774fd182f03ebba5e3c77ad (patch)
tree892f4baee51b2d74560555609bc927c052b57d50 /apps
parent7f24d42ca5f70e5ed48cf800f0a8f134b9445d2e (diff)
downloadnextcloud-server-48d63a6278078d164774fd182f03ebba5e3c77ad.tar.gz
nextcloud-server-48d63a6278078d164774fd182f03ebba5e3c77ad.zip
Return unencrypted_size of folder when queried
This fixes the "used space" to be based on the unencrypted size, not encrypted size, to be consistent with how quota/space is handled when encryption is enabled
Diffstat (limited to 'apps')
-rw-r--r--apps/files_encryption/lib/proxy.php7
-rw-r--r--apps/files_encryption/tests/proxy.php20
2 files changed, 27 insertions, 0 deletions
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index a2d42c22c13..b7e1599c1fe 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -340,6 +340,13 @@ class Proxy extends \OC_FileProxy {
// if path is a folder do nothing
if ($view->is_dir($path)) {
+ $proxyState = \OC_FileProxy::$enabled;
+ \OC_FileProxy::$enabled = false;
+ $fileInfo = $view->getFileInfo($path);
+ \OC_FileProxy::$enabled = $proxyState;
+ if ($fileInfo['unencrypted_size'] > 0) {
+ return $fileInfo['unencrypted_size'];
+ }
return $size;
}
diff --git a/apps/files_encryption/tests/proxy.php b/apps/files_encryption/tests/proxy.php
index 51cc0b795e3..647ee955eb1 100644
--- a/apps/files_encryption/tests/proxy.php
+++ b/apps/files_encryption/tests/proxy.php
@@ -112,4 +112,24 @@ class Test_Encryption_Proxy extends \PHPUnit_Framework_TestCase {
}
+ function testPostFileSizeWithDirectory() {
+
+ $this->view->file_put_contents($this->filename, $this->data);
+
+ \OC_FileProxy::$enabled = false;
+
+ // get root size, must match the file's unencrypted size
+ $unencryptedSize = $this->view->filesize('');
+
+ \OC_FileProxy::$enabled = true;
+
+ $encryptedSize = $this->view->filesize('');
+
+ $this->assertTrue($encryptedSize !== $unencryptedSize);
+
+ // cleanup
+ $this->view->unlink($this->filename);
+
+ }
+
}