Unsharing a single file now works

This commit is contained in:
Sam Tuke 2013-02-27 15:31:23 +00:00
parent aae9b0b1bf
commit 14eae441eb
2 changed files with 13 additions and 3 deletions

View File

@ -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;

View File

@ -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;
}
/**