summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2013-06-25 17:17:41 +0200
committerBjörn Schießle <schiessle@owncloud.com>2013-07-05 16:00:25 +0200
commitae30eb48f26d5f7bf3f7cf83e9ef56ca9cdbcf3d (patch)
tree6ee0dc9504c29df31199a73d544972b0f02a9b85 /apps
parentf9c337dd2149248be717f870bdba79ac21868bbe (diff)
downloadnextcloud-server-ae30eb48f26d5f7bf3f7cf83e9ef56ca9cdbcf3d.tar.gz
nextcloud-server-ae30eb48f26d5f7bf3f7cf83e9ef56ca9cdbcf3d.zip
make trash bin aware of system wide mounts with respect to encryption keys
Diffstat (limited to 'apps')
-rw-r--r--apps/files_trashbin/lib/trash.php28
1 files changed, 21 insertions, 7 deletions
diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php
index 1235d9d2ee0..b9d900dfab4 100644
--- a/apps/files_trashbin/lib/trash.php
+++ b/apps/files_trashbin/lib/trash.php
@@ -171,13 +171,19 @@ class Trashbin {
list($owner, $ownerPath) = self::getUidAndFilename($file_path);
+ $util = new \OCA\Encryption\Util(new \OC_FilesystemView('/'), $user);
// disable proxy to prevent recursive calls
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
- // retain key files
- $keyfile = \OC\Files\Filesystem::normalizePath($owner . '/files_encryption/keyfiles/' . $ownerPath);
+ if ($util->isSystemWideMountPoint($ownerPath)) {
+ $baseDir = '/files_encryption/';
+ } else {
+ $baseDir = $owner . '/files_encryption/';
+ }
+
+ $keyfile = \OC\Files\Filesystem::normalizePath($baseDir . '/keyfiles/' . $ownerPath);
if ($rootView->is_dir($keyfile) || $rootView->file_exists($keyfile . '.key')) {
// move keyfiles
@@ -191,7 +197,7 @@ class Trashbin {
}
// retain share keys
- $sharekeys = \OC\Files\Filesystem::normalizePath($owner . '/files_encryption/share-keys/' . $ownerPath);
+ $sharekeys = \OC\Files\Filesystem::normalizePath($baseDir . '/share-keys/' . $ownerPath);
if ($rootView->is_dir($sharekeys)) {
$size += self::calculateSize(new \OC\Files\View($sharekeys));
@@ -403,6 +409,14 @@ class Trashbin {
list($owner, $ownerPath) = self::getUidAndFilename($target);
+ $util = new \OCA\Encryption\Util(new \OC_FilesystemView('/'), $user);
+
+ if ($util->isSystemWideMountPoint($ownerPath)) {
+ $baseDir = '/files_encryption/';
+ } else {
+ $baseDir = $owner . '/files_encryption/';
+ }
+
$path_parts = pathinfo($file);
$source_location = $path_parts['dirname'];
@@ -432,18 +446,18 @@ class Trashbin {
// handle keyfiles
$size += self::calculateSize(new \OC\Files\View($keyfile));
- $rootView->rename($keyfile, $owner . '/files_encryption/keyfiles/' . $ownerPath);
+ $rootView->rename($keyfile, $baseDir . '/keyfiles/' . $ownerPath);
// handle share-keys
if ($timestamp) {
$sharekey .= '.d' . $timestamp;
}
$size += self::calculateSize(new \OC\Files\View($sharekey));
- $rootView->rename($sharekey, $owner . '/files_encryption/share-keys/' . $ownerPath);
+ $rootView->rename($sharekey, $baseDir . '/share-keys/' . $ownerPath);
} else {
// handle keyfiles
$size += $rootView->filesize($keyfile);
- $rootView->rename($keyfile, $owner . '/files_encryption/keyfiles/' . $ownerPath . '.key');
+ $rootView->rename($keyfile, $baseDir . '/keyfiles/' . $ownerPath . '.key');
// handle share-keys
$ownerShareKey = \OC\Files\Filesystem::normalizePath($user . '/files_trashbin/share-keys/' . $source_location . '/' . $filename . '.' . $user . '.shareKey');
@@ -454,7 +468,7 @@ class Trashbin {
$size += $rootView->filesize($ownerShareKey);
// move only owners key
- $rootView->rename($ownerShareKey, $owner . '/files_encryption/share-keys/' . $ownerPath . '.' . $user . '.shareKey');
+ $rootView->rename($ownerShareKey, $baseDir . '/share-keys/' . $ownerPath . '.' . $user . '.shareKey');
// try to re-share if file is shared
$filesystemView = new \OC_FilesystemView('/');