diff options
author | Björn Schießle <schiessle@owncloud.com> | 2013-04-22 15:29:58 +0200 |
---|---|---|
committer | Björn Schießle <schiessle@owncloud.com> | 2013-04-22 15:29:58 +0200 |
commit | a4364a93d0e80e0d1daa2b28713df05c25970fd1 (patch) | |
tree | ffbb6108a600e2b1396a1e59d49b8554891449b4 /apps/files_encryption/lib/keymanager.php | |
parent | b5cb5dab513441b8c914aaa043921d0affae4604 (diff) | |
download | nextcloud-server-a4364a93d0e80e0d1daa2b28713df05c25970fd1.tar.gz nextcloud-server-a4364a93d0e80e0d1daa2b28713df05c25970fd1.zip |
delete all share keys if a file gets deleted
Diffstat (limited to 'apps/files_encryption/lib/keymanager.php')
-rwxr-xr-x | apps/files_encryption/lib/keymanager.php | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php index 6fb1f128b5e..9885f5e5508 100755 --- a/apps/files_encryption/lib/keymanager.php +++ b/apps/files_encryption/lib/keymanager.php @@ -391,7 +391,26 @@ class Keymanager { return $result; } - + + /** + * @brief delete all share keys of a given file + * @param \OC_FilesystemView $view + * @param type $userId owner of the file + * @param type $filePath path to the file, relative to the owners file dir + */ + public static function delAllShareKeys(\OC_FilesystemView $view, $userId, $filePath) { + + if ($view->is_dir($userId.'/files/'.$filePath)) { + $view->unlink($userId.'/files_encryption/share-keys/'.$filePath); + } else { + $localKeyPath = $view->getLocalFile($userId.'/files_encryption/share-keys/'.$filePath); + $matches = glob(preg_quote($localKeyPath).'*.shareKey'); + foreach ($matches as $ma) { + unlink($ma); + } + } + } + /** * @brief Delete a single user's shareKey for a single file */ |