make trash bin aware of system wide mounts with respect to encryption keys

This commit is contained in:
Björn Schießle 2013-06-25 17:17:41 +02:00
parent f9c337dd21
commit ae30eb48f2
1 changed files with 21 additions and 7 deletions

View File

@ -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('/');