aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/lib
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2013-11-21 10:33:37 +0100
committerBjoern Schiessle <schiessle@owncloud.com>2013-11-21 10:33:37 +0100
commit16b484209c4792ce8c43f197d678e3fb393b3ee5 (patch)
treef256bbf248d9680061898ebd8f4aa1f292fc7733 /apps/files_encryption/lib
parent2b361ea085812a7b97102d026c421905549b5142 (diff)
parent391f267d380f0d098d730d3bc74633192cc13570 (diff)
downloadnextcloud-server-16b484209c4792ce8c43f197d678e3fb393b3ee5.tar.gz
nextcloud-server-16b484209c4792ce8c43f197d678e3fb393b3ee5.zip
Merge branch 'master' into encryption_work_with_public_gallery
Conflicts: apps/files_encryption/lib/keymanager.php apps/files_encryption/lib/stream.php apps/files_encryption/lib/util.php apps/files_encryption/tests/crypt.php
Diffstat (limited to 'apps/files_encryption/lib')
-rwxr-xr-xapps/files_encryption/lib/keymanager.php1
-rw-r--r--apps/files_encryption/lib/proxy.php3
-rw-r--r--apps/files_encryption/lib/stream.php3
-rw-r--r--apps/files_encryption/lib/util.php21
4 files changed, 15 insertions, 13 deletions
diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php
index b207b1437ba..4695673a48b 100755
--- a/apps/files_encryption/lib/keymanager.php
+++ b/apps/files_encryption/lib/keymanager.php
@@ -181,6 +181,7 @@ class Keymanager {
*/
public static function getFileKey(\OC_FilesystemView $view, $util, $filePath) {
+
list($owner, $filename) = $util->getUidAndFilename($filePath);
$filename = Helper::stripPartialFileExtension($filename);
$filePath_f = ltrim($filename, '/');
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index f7253b4591b..b0b2b62aa1b 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -350,7 +350,10 @@ class Proxy extends \OC_FileProxy {
$fileInfo = false;
// get file info from database/cache if not .part file
if (!Helper::isPartialFilePath($path)) {
+ $proxyState = \OC_FileProxy::$enabled;
+ \OC_FileProxy::$enabled = false;
$fileInfo = $view->getFileInfo($path);
+ \OC_FileProxy::$enabled = $proxyState;
}
// if file is encrypted return real file size
diff --git a/apps/files_encryption/lib/stream.php b/apps/files_encryption/lib/stream.php
index 409c6ff6273..4b0156e661e 100644
--- a/apps/files_encryption/lib/stream.php
+++ b/apps/files_encryption/lib/stream.php
@@ -497,7 +497,8 @@ class Stream {
if (
$this->meta['mode'] !== 'r' &&
$this->meta['mode'] !== 'rb' &&
- $this->size > 0
+ $this->size > 0 &&
+ $this->unencryptedSize > 0
) {
// only write keyfiles if it was a new file
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 2dd4fd9c163..a9468e34d41 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -455,22 +455,19 @@ class Util {
*/
public function isEncryptedPath($path) {
- // Disable encryption proxy so data retrieved is in its
- // original form
- $proxyStatus = \OC_FileProxy::$enabled;
- \OC_FileProxy::$enabled = false;
+ $relPath = Helper::getPathToRealFile($path);
- // we only need 24 byte from the last chunk
- $data = '';
- $handle = $this->view->fopen($path, 'r');
- if (is_resource($handle) && !fseek($handle, -24, SEEK_END)) {
- $data = fgets($handle);
+ if ($relPath === false) {
+ $relPath = Helper::stripUserFilesPath($path);
}
- // re-enable proxy
- \OC_FileProxy::$enabled = $proxyStatus;
+ $fileKey = Keymanager::getFileKey($this->view, $relPath);
- return Crypt::isCatfileContent($data);
+ if ($fileKey === false) {
+ return false;
+ }
+
+ return true;
}