summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Karlitschek <frank@owncloud.org>2014-07-06 10:38:06 -0400
committerFrank Karlitschek <frank@owncloud.org>2014-07-06 10:38:06 -0400
commita4686876822624a47435ab045568222b3971c083 (patch)
treebd7f8eaaf6e1cb04864cfb00f477e0c95ded427f
parent1f29bd18e91e83f48c2f4d3c8f345ec9e9172a36 (diff)
parent5397101e1cc1d54896c6572094337dd5777e1072 (diff)
downloadnextcloud-server-a4686876822624a47435ab045568222b3971c083.tar.gz
nextcloud-server-a4686876822624a47435ab045568222b3971c083.zip
Merge pull request #9453 from owncloud/enc_fix_wrong_file_size
[encryption] always take unencrypted size
-rw-r--r--apps/files_encryption/lib/proxy.php4
-rw-r--r--apps/files_encryption/tests/proxy.php12
2 files changed, 10 insertions, 6 deletions
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index b1af4676852..852b9111c12 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -157,8 +157,8 @@ class Proxy extends \OC_FileProxy {
// store new unenecrypted size so that it can be updated
// in the post proxy
$tmpFileInfo = $view->getFileInfo($tmpPath);
- if ( isset($tmpFileInfo['size']) ) {
- self::$unencryptedSizes[\OC\Files\Filesystem::normalizePath($path)] = $tmpFileInfo['size'];
+ if ( isset($tmpFileInfo['unencrypted_size']) ) {
+ self::$unencryptedSizes[\OC\Files\Filesystem::normalizePath($path)] = $tmpFileInfo['unencrypted_size'];
}
// remove our temp file
diff --git a/apps/files_encryption/tests/proxy.php b/apps/files_encryption/tests/proxy.php
index 8d6bc81b08d..9ec1f940edd 100644
--- a/apps/files_encryption/tests/proxy.php
+++ b/apps/files_encryption/tests/proxy.php
@@ -47,6 +47,7 @@ class Test_Encryption_Proxy extends \PHPUnit_Framework_TestCase {
public $view; // view in /data/user/files
public $rootView; // view on /data/user
public $data;
+ public $dataLong;
public $filename;
public static function setUpBeforeClass() {
@@ -80,6 +81,7 @@ class Test_Encryption_Proxy extends \PHPUnit_Framework_TestCase {
// init short data
$this->data = 'hats';
+ $this->dataLong = file_get_contents(__DIR__ . '/../lib/crypt.php');
$this->filename = 'enc_proxy_tests-' . uniqid() . '.txt';
}
@@ -95,17 +97,19 @@ class Test_Encryption_Proxy extends \PHPUnit_Framework_TestCase {
*/
function testPostFileSize() {
- $this->view->file_put_contents($this->filename, $this->data);
+ $this->view->file_put_contents($this->filename, $this->dataLong);
+ $size = strlen($this->dataLong);
\OC_FileProxy::$enabled = false;
- $unencryptedSize = $this->view->filesize($this->filename);
+ $encryptedSize = $this->view->filesize($this->filename);
\OC_FileProxy::$enabled = true;
- $encryptedSize = $this->view->filesize($this->filename);
+ $unencryptedSize = $this->view->filesize($this->filename);
- $this->assertTrue($encryptedSize !== $unencryptedSize);
+ $this->assertTrue($encryptedSize > $unencryptedSize);
+ $this->assertSame($size, $unencryptedSize);
// cleanup
$this->view->unlink($this->filename);