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

@ -363,14 +363,21 @@ class Keymanager {
\OC_FileProxy::$enabled = false;
$trimmed = ltrim( $filePath, '/' );
$shareKeyPath = '/' . $userId . '/files_encryption/share-keys/' . $trimmed . '.shareKey';
$util = new Util( $view, $userId );
// Unlink doesn't tell us if file was deleted (not found returns
// true), so we perform our own test
if ( $view->file_exists( $shareKeyPath ) ) {
list($owner, $filename) = $util->getUidAndFilename($filePath);
$result = $view->unlink( $shareKeyPath );
$shareKeyPath = '/' . $owner . '/files_encryption/share-keys/' . $filename;
$absPath = $view->getLocalFile($shareKeyPath);
$matches = glob(preg_quote($absPath).'.*.shareKey' );
if ( $matches ) {
foreach ( $matches as $ma ) {
unlink($ma);
}
} else {