summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2013-02-20 22:17:04 +0100
committerBjörn Schießle <schiessle@owncloud.com>2013-02-20 22:17:04 +0100
commitb685aa8bcb0abf0d406cc349b37a327319d46e62 (patch)
tree516da988732dc4fdeb892d993f7413768e6dd6d9 /apps
parent5329c9ea31a1e0c31756d4faf8a9946965032012 (diff)
downloadnextcloud-server-b685aa8bcb0abf0d406cc349b37a327319d46e62.tar.gz
nextcloud-server-b685aa8bcb0abf0d406cc349b37a327319d46e62.zip
some fixes for the keyfile handling
Diffstat (limited to 'apps')
-rw-r--r--apps/files_trashbin/lib/trash.php38
1 files changed, 28 insertions, 10 deletions
diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php
index 4d230449b59..f11e5c4cbfd 100644
--- a/apps/files_trashbin/lib/trash.php
+++ b/apps/files_trashbin/lib/trash.php
@@ -69,7 +69,7 @@ class Trashbin {
return;
}
- // Take core of file versions
+ // Take care of file versions
if ( \OCP\App::isEnabled('files_versions') ) {
if ( $view->is_dir('files_versions'.$file_path) ) {
$trashbinSize += self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_versions/'.$file_path));
@@ -86,11 +86,12 @@ class Trashbin {
$keyfile = \OC_Filesystem::normalizePath('files_encryption/keyfiles/'.$file_path);
if ( \OCP\App::isEnabled('files_encryption') && $view->file_exists($keyfile.'.key') ) {
if ( $view->is_dir('files'.$file_path) ) {
- $trashbinSize -= self::calculateSize(new \OC_FilesystemView('/'.$user.'/'.$keyfile));
+ $trashbinSize += self::calculateSize(new \OC_FilesystemView('/'.$user.'/'.$keyfile));
+ $view->rename($keyfile, 'files_trashbin/keyfiles/'. $deleted.'.d'.$timestamp);
} else {
$trashbinSize += $view->filesize($keyfile.'.key');
+ $view->rename($keyfile.'.key', 'files_trashbin/keyfiles/'. $deleted.'.key.d'.$timestamp);
}
- $view->rename($keyfile.'.key', 'files_trashbin/keyfiles/'. $deleted.'.d'.$timestamp);
}
} else {
@@ -149,7 +150,7 @@ class Trashbin {
$location = '';
}
} else {
- $path_parts = pathinfo($filename);
+ $path_parts = pathinfo($file);
$result[] = array(
'location' => $path_parts['dirname'],
'type' => $view->is_dir('/files_trashbin/files/'.$file) ? 'dir' : 'files',
@@ -193,15 +194,24 @@ class Trashbin {
}
}
- // Take care of encryption keys
- $keyfile = \OC_Filesystem::normalizePath('files_trashbin/keyfiles/'.$file);
+ // Take care of encryption keys TODO! Get '.key' in file between file name and delete date (also for permanent delete!)
+ $parts = pathinfo($file);
+ if ( $result[0]['type'] == 'dir' ) {
+ $keyfile = \OC_Filesystem::normalizePath('files_trashbin/keyfiles/'.$parts['dirname'].'/'.$filename);
+ } else {
+ $keyfile = \OC_Filesystem::normalizePath('files_trashbin/keyfiles/'.$parts['dirname'].'/'.$filename.'.key');
+ }
+ if ($timestamp) {
+ $keyfile .= '.d'.$timestamp;
+ }
if ( \OCP\App::isEnabled('files_encryption') && $view->file_exists($keyfile) ) {
if ( $result[0]['type'] == 'dir' ) {
$trashbinSize -= self::calculateSize(new \OC_FilesystemView('/'.$user.'/'.$keyfile));
+ $view->rename($keyfile, 'files_encryption/keyfiles/'. $location.'/'.$filename);
} else {
$trashbinSize -= $view->filesize($keyfile);
+ $view->rename($keyfile, 'files_encryption/keyfiles/'. $location.'/'.$filename.'.key');
}
- $view->rename($keyfile, 'files_encryption/keyfiles/'. $location.'/'.$filename.'.key');
}
if ( $timestamp ) {
@@ -258,10 +268,18 @@ class Trashbin {
}
}
- // Take care of encryption keys
- $keyfile = \OC_Filesystem::normalizePath('files_trashbin/keyfiles/'.$file);
+ // Take care of encryption keys
+ $parts = pathinfo($file);
+ if ( $view->is_dir('/files_trashbin/files/'.$file) ) {
+ $keyfile = \OC_Filesystem::normalizePath('files_trashbin/keyfiles/'.$filename);
+ } else {
+ $keyfile = \OC_Filesystem::normalizePath('files_trashbin/keyfiles/'.$filename.'.key');
+ }
+ if ($timestamp) {
+ $keyfile .= '.d'.$timestamp;
+ }
if ( \OCP\App::isEnabled('files_encryption') && $view->file_exists($keyfile) ) {
- if ( $result[0]['type'] == 'dir' ) {
+ if ( $view->is_dir($keyfile) ) {
$size += self::calculateSize(new \OC_FilesystemView('/'.$user.'/'.$keyfile));
} else {
$size += $view->filesize($keyfile);