summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption
diff options
context:
space:
mode:
authorSam Tuke <samtuke@owncloud.com>2013-01-30 17:25:17 +0000
committerSam Tuke <samtuke@owncloud.com>2013-01-30 17:25:17 +0000
commit61b23ce6cc4c9e21da1dd161f11fc15b878027fd (patch)
tree811903788e92335299e3f8774b02ec4a331b3609 /apps/files_encryption
parentc1f20fe37a28c6f596dd55a27962d77d0ade1892 (diff)
downloadnextcloud-server-61b23ce6cc4c9e21da1dd161f11fc15b878027fd.tar.gz
nextcloud-server-61b23ce6cc4c9e21da1dd161f11fc15b878027fd.zip
Working on support for deleting directories (removing all keyfiles)
Diffstat (limited to 'apps/files_encryption')
-rw-r--r--apps/files_encryption/lib/proxy.php32
1 files changed, 19 insertions, 13 deletions
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index 6d2a574abd2..9e1dbfe0d37 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -195,27 +195,37 @@ class Proxy extends \OC_FileProxy {
/**
* @brief When a file is deleted, remove its keyfile also
*/
- public function postUnlink( $path ) {
+ public function preUnlink( $path ) {
// Disable encryption proxy to prevent recursive calls
\OC_FileProxy::$enabled = false;
$view = new \OC_FilesystemView( '/' );
- $userId = \OCP\USER::getUser();
-
// Format path to be relative to user files dir
$trimmed = ltrim( $path, '/' );
$split = explode( '/', $trimmed );
$sliced = array_slice( $split, 2 );
$relPath = implode( '/', $sliced );
-
- // Delete keyfile so it isn't orphaned
- $result = Keymanager::deleteFileKey( $view, $userId, $relPath );
-
- \OC_FileProxy::$enabled = true;
- return $result;
+ if ( $view->is_dir( $path ) ) {
+
+ // Dirs must be handled separately as deleteFileKey
+ // doesn't handle them
+ $view->unlink( 'files_encryption/keyfiles/'. $relPath );
+
+ } else {
+
+ $userId = \OCP\USER::getUser();
+
+ // Delete keyfile so it isn't orphaned
+ $result = Keymanager::deleteFileKey( $view, $userId, $relPath );
+
+ \OC_FileProxy::$enabled = true;
+
+ return $result;
+
+ }
}
@@ -225,8 +235,6 @@ class Proxy extends \OC_FileProxy {
* @note This is pre rather than post because using post didn't work
*/
public function preRename( $oldPath, $newPath ) {
-
-// trigger_error( "PATHS = ".var_export($oldPath, 1).' '.var_export($newPath, 1));
// Disable encryption proxy to prevent recursive calls
\OC_FileProxy::$enabled = false;
@@ -248,8 +256,6 @@ class Proxy extends \OC_FileProxy {
$newRelPath = implode( '/', $newSliced );
$newKeyfilePath = $userId . '/' . 'files_encryption' . '/' . 'keyfiles' . '/' . $newRelPath . '.key';
-// trigger_error("RENAMING = ".var_export($oldKeyfilePath, 1).' -> '.var_export($newKeyfilePath, 1));
-
// Rename keyfile so it isn't orphaned
$result = $view->rename( $oldKeyfilePath, $newKeyfilePath );