delete share keys if file gets deleted

This commit is contained in:
Björn Schießle 2013-03-26 14:22:18 +01:00
parent 5f233ee814
commit b1d620300e
1 changed files with 17 additions and 10 deletions

View File

@ -362,16 +362,23 @@ class Keymanager {
public static function delShareKey( \OC_FilesystemView $view, $userId, $filePath ) { public static function delShareKey( \OC_FilesystemView $view, $userId, $filePath ) {
\OC_FileProxy::$enabled = false; \OC_FileProxy::$enabled = false;
$trimmed = ltrim( $filePath, '/' ); $util = new Util( $view, $userId );
$shareKeyPath = '/' . $userId . '/files_encryption/share-keys/' . $trimmed . '.shareKey';
list($owner, $filename) = $util->getUidAndFilename($filePath);
// Unlink doesn't tell us if file was deleted (not found returns
// true), so we perform our own test $shareKeyPath = '/' . $owner . '/files_encryption/share-keys/' . $filename;
if ( $view->file_exists( $shareKeyPath ) ) {
$absPath = $view->getLocalFile($shareKeyPath);
$result = $view->unlink( $shareKeyPath );
$matches = glob(preg_quote($absPath).'.*.shareKey' );
if ( $matches ) {
foreach ( $matches as $ma ) {
unlink($ma);
}
} else { } else {
\OC_Log::write( 'Encryption library', 'Could not delete shareKey; does not exist: "' . $shareKeyPath, \OC_Log::ERROR ); \OC_Log::write( 'Encryption library', 'Could not delete shareKey; does not exist: "' . $shareKeyPath, \OC_Log::ERROR );