handle rename correctly for system wide mounts

This commit is contained in:
Björn Schießle 2013-06-25 14:42:49 +02:00
parent eb2587a08f
commit abc2ee2e07
1 changed files with 16 additions and 9 deletions

View File

@ -476,10 +476,19 @@ class Hooks {
$util = new Util($view, $userId); $util = new Util($view, $userId);
// Format paths to be relative to user files dir // Format paths to be relative to user files dir
$oldKeyfilePath = \OC\Files\Filesystem::normalizePath( if ($util->isSystemWideMountPoint($params['oldpath'])) {
$userId . '/' . 'files_encryption' . '/' . 'keyfiles' . '/' . $params['oldpath']); $baseDir = 'files_encryption/';
$newKeyfilePath = \OC\Files\Filesystem::normalizePath( $oldKeyfilePath = $baseDir . 'keyfiles/' . $params['oldpath'];
$userId . '/' . 'files_encryption' . '/' . 'keyfiles' . '/' . $params['newpath']); } else {
$baseDir = $userId . '/' . 'files_encryption/';
$oldKeyfilePath = $baseDir . 'keyfiles/' . $params['oldpath'];
}
if ($util->isSystemWideMountPoint($params['newpath'])) {
$newKeyfilePath = $baseDir . 'keyfiles/' . $params['newpath'];
} else {
$newKeyfilePath = $baseDir . 'keyfiles/' . $params['newpath'];
}
// add key ext if this is not an folder // add key ext if this is not an folder
if (!$view->is_dir($oldKeyfilePath)) { if (!$view->is_dir($oldKeyfilePath)) {
@ -487,7 +496,7 @@ class Hooks {
$newKeyfilePath .= '.key'; $newKeyfilePath .= '.key';
// handle share-keys // handle share-keys
$localKeyPath = $view->getLocalFile($userId . '/files_encryption/share-keys/' . $params['oldpath']); $localKeyPath = $view->getLocalFile($baseDir . 'share-keys/' . $params['oldpath']);
$matches = glob(preg_quote($localKeyPath) . '*.shareKey'); $matches = glob(preg_quote($localKeyPath) . '*.shareKey');
foreach ($matches as $src) { foreach ($matches as $src) {
$dst = \OC\Files\Filesystem::normalizePath(str_replace($params['oldpath'], $params['newpath'], $src)); $dst = \OC\Files\Filesystem::normalizePath(str_replace($params['oldpath'], $params['newpath'], $src));
@ -502,10 +511,8 @@ class Hooks {
} else { } else {
// handle share-keys folders // handle share-keys folders
$oldShareKeyfilePath = \OC\Files\Filesystem::normalizePath( $oldShareKeyfilePath = $baseDir . 'share-keys/' . $params['oldpath'];
$userId . '/' . 'files_encryption' . '/' . 'share-keys' . '/' . $params['oldpath']); $newShareKeyfilePath = $baseDir . 'share-keys/' . $params['newpath'];
$newShareKeyfilePath = \OC\Files\Filesystem::normalizePath(
$userId . '/' . 'files_encryption' . '/' . 'share-keys' . '/' . $params['newpath']);
// create destination folder if not exists // create destination folder if not exists
if (!$view->file_exists(dirname($newShareKeyfilePath))) { if (!$view->file_exists(dirname($newShareKeyfilePath))) {