diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-03-10 09:38:24 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-03-10 09:38:24 +0100 |
commit | 26513bc17b1119060819e391c3faf2a391769f70 (patch) | |
tree | b54e65ff4c86b315a3ab685a17293e9504d99337 /apps | |
parent | 212699e389e12e8f9fa7f30992b9b799c11c0299 (diff) | |
parent | 48d63a6278078d164774fd182f03ebba5e3c77ad (diff) | |
download | nextcloud-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 'apps')
-rw-r--r-- | apps/files_encryption/lib/proxy.php | 7 | ||||
-rw-r--r-- | apps/files_encryption/tests/proxy.php | 20 |
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); + + } + } |