From 14eae441eb77ee53304d8a164deb146bda4020f4 Mon Sep 17 00:00:00 2001 From: Sam Tuke Date: Wed, 27 Feb 2013 15:31:23 +0000 Subject: [PATCH] Unsharing a single file now works --- apps/files_encryption/hooks/hooks.php | 4 +++- apps/files_encryption/lib/keymanager.php | 12 ++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php index bf16a492e33..fb3545208d2 100644 --- a/apps/files_encryption/hooks/hooks.php +++ b/apps/files_encryption/hooks/hooks.php @@ -245,11 +245,13 @@ class Hooks { $util = new Util( $view, $userId ); $path = $util->fileIdToPath( $params['itemSource'] ); + // If path is a folder, get all children $allPaths = $util->getPaths( $path ); foreach ( $allPaths as $path ) { - if ( ! Keymanager::delShareKey( $view, $userId, $path ) ) { + // Unshare each child path + if ( ! Keymanager::delShareKey( $view, $params['shareWith'], $path ) ) { $failed[] = $path; diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php index 22e2ffa500e..62bb12bf90d 100755 --- a/apps/files_encryption/lib/keymanager.php +++ b/apps/files_encryption/lib/keymanager.php @@ -355,6 +355,8 @@ class Keymanager { */ public static function delShareKey( \OC_FilesystemView $view, $userId, $filePath ) { + \OC_FileProxy::$enabled = false; + $trimmed = ltrim( $filePath, '/' ); $shareKeyPath = '/' . $userId . '/files_encryption/share-keys/' . $trimmed . '.shareKey'; @@ -362,16 +364,22 @@ class Keymanager { // true), so we perform our own test if ( $view->file_exists( $shareKeyPath ) ) { - return $view->unlink( $shareKeyPath ); + $result = $view->unlink( $shareKeyPath ); } else { + trigger_error("Could not delete shareKey; does not exist: $shareKeyPath"); + \OC_Log::write( 'Encryption library', 'Could not delete shareKey; does not exist: "' . $shareKeyPath, \OC_Log::ERROR ); - return false; + $result = false; } + \OC_FileProxy::$enabled = false; + + return $result; + } /** -- 2.39.5