summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-06-04 10:26:02 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2014-06-04 10:26:02 +0200
commit4ab77f90d2645f503f077903020c6bd56415294a (patch)
tree621250352a8da7db1112f08b1bcaf7b4b3676b0e /apps
parent9e31118675d425b99eff340ec7517e478ebc9fcf (diff)
parent917f389747dc3b8b3d5b9ff326a2cee21579f58a (diff)
downloadnextcloud-server-4ab77f90d2645f503f077903020c6bd56415294a.tar.gz
nextcloud-server-4ab77f90d2645f503f077903020c6bd56415294a.zip
Merge pull request #8662 from owncloud/f-lock
f-lock
Diffstat (limited to 'apps')
-rw-r--r--apps/files_encryption/hooks/hooks.php10
-rw-r--r--apps/files_encryption/lib/proxy.php9
-rw-r--r--apps/files_encryption/tests/stream.php6
-rwxr-xr-xapps/files_encryption/tests/webdav.php9
4 files changed, 21 insertions, 13 deletions
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php
index 8fae901fe63..d1ee4a97d15 100644
--- a/apps/files_encryption/hooks/hooks.php
+++ b/apps/files_encryption/hooks/hooks.php
@@ -99,12 +99,14 @@ class Hooks {
// Set legacy encryption key if it exists, to support
// depreciated encryption system
- $encLegacyKey = $userView->file_get_contents('encryption.key');
- if ($encLegacyKey) {
+ if ($userView->file_exists('encryption.key')) {
+ $encLegacyKey = $userView->file_get_contents('encryption.key');
+ if ($encLegacyKey) {
- $plainLegacyKey = Crypt::legacyDecrypt($encLegacyKey, $params['password']);
+ $plainLegacyKey = Crypt::legacyDecrypt($encLegacyKey, $params['password']);
- $session->setLegacyKey($plainLegacyKey);
+ $session->setLegacyKey($plainLegacyKey);
+ }
}
// Encrypt existing user files
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index ae3df834e9f..fd91073b8de 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -275,7 +275,7 @@ class Proxy extends \OC_FileProxy {
\OC_FileProxy::$enabled = false;
// get file size
- $data['size'] = self::postFileSize($path, $data['size']);
+ $data['size'] = self::postFileSize($path, $data['size'], $data);
// Re-enable the proxy
\OC_FileProxy::$enabled = $proxyStatus;
@@ -289,7 +289,7 @@ class Proxy extends \OC_FileProxy {
* @param int $size
* @return int|bool
*/
- public function postFileSize($path, $size) {
+ public function postFileSize($path, $size, $fileInfo = null) {
$view = new \OC\Files\View('/');
@@ -323,9 +323,8 @@ class Proxy extends \OC_FileProxy {
return $size;
}
- $fileInfo = false;
// get file info from database/cache if not .part file
- if (!Helper::isPartialFilePath($path)) {
+ if (empty($fileInfo) && !Helper::isPartialFilePath($path)) {
$proxyState = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
$fileInfo = $view->getFileInfo($path);
@@ -333,7 +332,7 @@ class Proxy extends \OC_FileProxy {
}
// if file is encrypted return real file size
- if ($fileInfo && $fileInfo['encrypted'] === true) {
+ if (isset($fileInfo['encrypted']) && $fileInfo['encrypted'] === true) {
// try to fix unencrypted file size if it doesn't look plausible
if ((int)$fileInfo['size'] > 0 && (int)$fileInfo['unencrypted_size'] === 0 ) {
$fixSize = $util->getFileSize($path);
diff --git a/apps/files_encryption/tests/stream.php b/apps/files_encryption/tests/stream.php
index 5df9cdbe1f1..254c5e87ed1 100644
--- a/apps/files_encryption/tests/stream.php
+++ b/apps/files_encryption/tests/stream.php
@@ -136,6 +136,8 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase {
// set stream options
$this->assertTrue(stream_set_blocking($handle, 1));
+ fclose($handle);
+
// tear down
$view->unlink($filename);
}
@@ -158,6 +160,8 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase {
// set stream options
$this->assertFalse(stream_set_timeout($handle, 1));
+ fclose($handle);
+
// tear down
$view->unlink($filename);
}
@@ -177,6 +181,8 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase {
// set stream options
$this->assertEquals(0, stream_set_write_buffer($handle, 1024));
+ fclose($handle);
+
// tear down
$view->unlink($filename);
}
diff --git a/apps/files_encryption/tests/webdav.php b/apps/files_encryption/tests/webdav.php
index d33dc58cf92..f299116ff23 100755
--- a/apps/files_encryption/tests/webdav.php
+++ b/apps/files_encryption/tests/webdav.php
@@ -49,7 +49,7 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase {
public $dataShort;
public $stateFilesTrashbin;
- private static $storage;
+ private $storage;
public static function setUpBeforeClass() {
// reset backend
@@ -69,7 +69,6 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase {
// create test user
\Test_Encryption_Util::loginHelper(\Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1, true);
- self::$storage = new \OC\Files\Storage\Temporary(array());
}
function setUp() {
@@ -83,7 +82,7 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase {
// init filesystem view
$this->view = new \OC\Files\View('/');
-
+ list($this->storage, $intPath) = $this->view->resolvePath('/');
// init short data
$this->dataShort = 'hats';
@@ -200,6 +199,9 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase {
$_SERVER['HTTP_AUTHORIZATION'] = 'Basic dGVzdC13ZWJkYXYtdXNlcjE6dGVzdC13ZWJkYXYtdXNlcjE=';
$_SERVER['PATH_INFO'] = '/webdav' . $filename;
+ // at the beginning the file should exist
+ $this->assertTrue($this->view->file_exists('/' . $this->userId . '/files' . $filename));
+
// handle webdav request
$content = $this->handleWebdavRequest();
@@ -230,7 +232,6 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase {
// Create ownCloud Dir
$root = '/' . $this->userId . '/files';
- \OC\Files\Filesystem::mount(self::$storage, array(), $root);
$view = new \OC\Files\View($root);
$publicDir = new OC_Connector_Sabre_Directory($view, $view->getFileInfo(''));
$objectTree = new \OC\Connector\Sabre\ObjectTree();