summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2013-06-10 11:03:07 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2013-07-29 13:36:06 +0200
commit2c8e5ec84ff98088fb9e3b275735098beaa5e27f (patch)
treee0cf14263f97b2b3296ca52a6422dbe74b0ad598 /apps/files_encryption
parent48621115c10f62f776dbe41ad9a51c1ac360fc8c (diff)
downloadnextcloud-server-2c8e5ec84ff98088fb9e3b275735098beaa5e27f.tar.gz
nextcloud-server-2c8e5ec84ff98088fb9e3b275735098beaa5e27f.zip
user interface to allow user to decrypt all his files once the encryption app was disabled
Conflicts: settings/templates/personal.php
Diffstat (limited to 'apps/files_encryption')
-rwxr-xr-xapps/files_encryption/lib/helper.php27
-rw-r--r--apps/files_encryption/lib/proxy.php6
-rw-r--r--apps/files_encryption/lib/stream.php14
3 files changed, 39 insertions, 8 deletions
diff --git a/apps/files_encryption/lib/helper.php b/apps/files_encryption/lib/helper.php
index 6eee8fed6a6..f5a5d269a69 100755
--- a/apps/files_encryption/lib/helper.php
+++ b/apps/files_encryption/lib/helper.php
@@ -199,6 +199,12 @@ class Helper {
public static function stripUserFilesPath($path) {
$trimmed = ltrim($path, '/');
$split = explode('/', $trimmed);
+
+ // it is not a file relative to data/user/files
+ if ($split[1] !== 'files') {
+ return false;
+ }
+
$sliced = array_slice($split, 2);
$relPath = implode('/', $sliced);
@@ -206,6 +212,27 @@ class Helper {
}
/**
+ * @brief get path to the correspondig file in data/user/files
+ * @param string $path path to a version or a file in the trash
+ * @return string path to correspondig file relative to data/user/files
+ */
+ public static function getPathToRealFile($path) {
+ $trimmed = ltrim($path, '/');
+ $split = explode('/', $trimmed);
+
+ if ($split[1] !== "files_versions") {
+ return false;
+ }
+
+ $sliced = array_slice($split, 2);
+ $realPath = implode('/', $sliced);
+ //remove the last .v
+ $realPath = substr($realPath, 0, strrpos($realPath, '.v'));
+
+ return $realPath;
+ }
+
+ /**
* @brief redirect to a error page
*/
public static function redirectToErrorPage() {
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index 735eba911a9..12fee750a6a 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -116,7 +116,7 @@ class Proxy extends \OC_FileProxy {
return true;
}
- $handle = fopen('crypt://' . $relativePath . '.etmp', 'w');
+ $handle = fopen('crypt://' . $path . '.etmp', 'w');
if (is_resource($handle)) {
// write data to stream
@@ -296,14 +296,14 @@ class Proxy extends \OC_FileProxy {
// Open the file using the crypto stream wrapper
// protocol and let it do the decryption work instead
- $result = fopen('crypt://' . $relativePath, $meta['mode']);
+ $result = fopen('crypt://' . $path, $meta['mode']);
} elseif (
self::shouldEncrypt($path)
and $meta ['mode'] !== 'r'
and $meta['mode'] !== 'rb'
) {
- $result = fopen('crypt://' . $relativePath, $meta['mode']);
+ $result = fopen('crypt://' . $path, $meta['mode']);
}
// Re-enable the proxy
diff --git a/apps/files_encryption/lib/stream.php b/apps/files_encryption/lib/stream.php
index 3c1eb2c5f5e..2f7af1410b9 100644
--- a/apps/files_encryption/lib/stream.php
+++ b/apps/files_encryption/lib/stream.php
@@ -73,7 +73,7 @@ class Stream {
private $privateKey;
/**
- * @param $path
+ * @param $path raw path relative to data/
* @param $mode
* @param $options
* @param $opened_path
@@ -93,12 +93,16 @@ class Stream {
$this->userId = $util->getUserId();
- // Strip identifier text from path, this gives us the path relative to data/<user>/files
- $this->relPath = \OC\Files\Filesystem::normalizePath(str_replace('crypt://', '', $path));
-
// rawPath is relative to the data directory
- $this->rawPath = $util->getUserFilesDir() . $this->relPath;
+ $this->rawPath = \OC\Files\Filesystem::normalizePath(str_replace('crypt://', '', $path));
+ // Strip identifier text from path, this gives us the path relative to data/<user>/files
+ $this->relPath = Helper::stripUserFilesPath($this->rawPath);
+ // if raw path doesn't point to a real file, check if it is a version or a file in the trash bin
+ if ($this->relPath === false) {
+ $this->relPath = Helper::getPathToRealFile($this->rawPath);
+ }
+
// Disable fileproxies so we can get the file size and open the source file without recursive encryption
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;