diff options
author | ringmaster <epithet@gmail.com> | 2014-05-23 18:29:37 +0400 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-06-05 18:47:37 +0400 |
commit | 6ec29711fc40895ed815c11e4b3a35fbfadd274e (patch) | |
tree | 87185063f287373fc2a64fba2cf90f0afdb0af5d /apps/files_encryption | |
parent | 49f29551199b23e6219c93375d03f73830c4eb54 (diff) |
Continued flock work.
add actual locking and log changes necessary for debugging.
Simpler log unique id.
Respect locked files, surface correct exception.
Conflicts:
lib/private/connector/sabre/file.php
Remove unused methods.
Conflicts:
lib/private/files/storage/local.php
Fix typo
Fix typo
Removed unused vars/declarations, update PHPDoc.
Don't error out on console.
Move Lock to private namespace, add interface. Update PHPDoc.
Restore the reference to this used exception class.
make sure to close the stream at the end of each test
Normalize lock exception messages.
don't ask for fileInfo if we already have one
Conflicts:
apps/files_encryption/lib/proxy.php
name the storage wrapper to make sure that we don't apply the wrapper multiple times
Conflicts:
lib/private/util.php
fix unit test after adding the additional parameter to addStorageWrapper()
only lock if unlink is called for a file
Can't use assertInstanceOf on wrapped storage; use assertTrue(instanceOfStorage() instead.
Conflicts:
tests/lib/files/filesystem.php
Use ->instanceOfStorage() not instanceof for Storage instances.
Conflicts:
lib/private/helper.php
get the storage from the view
Conflicts:
apps/files_encryption/tests/webdav.php
workaround to get the unit test going
Conflicts:
apps/files_encryption/hooks/hooks.php
Added isLocal() method to storage, used for xsendfile
Added isLocal() method to Storage to find out whether the storage is
local or not.
This method is used for the x-sendfile logic to find out whether to add
the headers.
Conflicts:
lib/private/files.php
Add ->instanceOfStorage to handle instanceof for storage wrappers
Conflicts:
lib/private/files/storage/common.php
lib/private/files/storage/wrapper/wrapper.php
lib/public/files/storage.php
Use instanceOfStorage instead of instanceof
Conflicts:
lib/private/files.php
Fix storage wrapper being called with null
Pass any methods custom to specific storage implementations to the wrapped storage
remove duplicate declaration of isLocal()
remove file locking - code will continue to live in it's own app
Diffstat (limited to 'apps/files_encryption')
-rw-r--r-- | apps/files_encryption/hooks/hooks.php | 6 | ||||
-rw-r--r-- | apps/files_encryption/lib/proxy.php | 9 | ||||
-rw-r--r-- | apps/files_encryption/tests/stream.php | 6 | ||||
-rwxr-xr-x | apps/files_encryption/tests/webdav.php | 16 |
4 files changed, 24 insertions, 13 deletions
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php index 8bfd0a7845f..0d050e12a95 100644 --- a/apps/files_encryption/hooks/hooks.php +++ b/apps/files_encryption/hooks/hooks.php @@ -101,11 +101,9 @@ class Hooks { $userView->file_exists('encryption.key')
&& $encLegacyKey = $userView->file_get_contents('encryption.key')
) {
+ $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 ef40c18183f..70278234b7c 100644 --- a/apps/files_encryption/lib/proxy.php +++ b/apps/files_encryption/lib/proxy.php @@ -311,7 +311,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; @@ -325,7 +325,7 @@ class Proxy extends \OC_FileProxy { * @param $size * @return bool */ - public function postFileSize($path, $size) { + public function postFileSize($path, $size, $fileInfo = null) { $view = new \OC_FilesystemView('/'); @@ -359,9 +359,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); @@ -369,7 +368,7 @@ class Proxy extends \OC_FileProxy { } // if file is encrypted return real file size - if (is_array($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 d26cd75648b..8b9dc38a761 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 8e8b9c53cee..bccab5befe4 100755 --- a/apps/files_encryption/tests/webdav.php +++ b/apps/files_encryption/tests/webdav.php @@ -48,6 +48,8 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase { public $dataShort; public $stateFilesTrashbin; + private $storage; + public static function setUpBeforeClass() { // reset backend \OC_User::clearBackends(); @@ -77,8 +79,8 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase { $this->pass = \Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1; // init filesystem view - $this->view = new \OC_FilesystemView('/'); - + $this->view = new \OC\Files\View('/'); + list($this->storage, $intPath) = $this->view->resolvePath('/'); // init short data $this->dataShort = 'hats'; @@ -196,6 +198,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(); @@ -225,10 +230,13 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase { $requestBackend = new OC_Connector_Sabre_Request(); // Create ownCloud Dir - $publicDir = new OC_Connector_Sabre_Directory(''); + $root = '/' . $this->userId . '/files'; + $view = new \OC\Files\View($root); + $publicDir = new OC_Connector_Sabre_Directory($view); + $objectTree = new \OC\Connector\Sabre\ObjectTree($publicDir); // Fire up server - $server = new Sabre_DAV_Server($publicDir); + $server = new Sabre_DAV_Server($objectTree); $server->httpRequest = $requestBackend; $server->setBaseUri('/remote.php/webdav/'); |