summaryrefslogtreecommitdiffstats
path: root/lib/private/Encryption
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2017-01-18 17:42:07 +0100
committerMorris Jobke <hey@morrisjobke.de>2017-03-17 00:07:23 -0600
commitaebb8c3639041dbbabd0825403675c053042f90b (patch)
tree0e99c50507dad49fa49c99b7f2c756749a72d96c /lib/private/Encryption
parent39afcbd49feb4ba333746762fe7c9d4701db9860 (diff)
downloadnextcloud-server-aebb8c3639041dbbabd0825403675c053042f90b.tar.gz
nextcloud-server-aebb8c3639041dbbabd0825403675c053042f90b.zip
Ignore exception when deleting keys of deleted user
Whenever a user was deleted for encryption where the keys are stored in the home, we can ignore user existence exceptions because it means the keys are already gone. Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'lib/private/Encryption')
-rw-r--r--lib/private/Encryption/Keys/Storage.php18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/private/Encryption/Keys/Storage.php b/lib/private/Encryption/Keys/Storage.php
index e8d152581fe..a4c3a26d7be 100644
--- a/lib/private/Encryption/Keys/Storage.php
+++ b/lib/private/Encryption/Keys/Storage.php
@@ -28,6 +28,7 @@ use OC\Encryption\Util;
use OC\Files\Filesystem;
use OC\Files\View;
use OCP\Encryption\Keys\IStorage;
+use OC\User\NoUserException;
class Storage implements IStorage {
@@ -134,8 +135,21 @@ class Storage implements IStorage {
* @inheritdoc
*/
public function deleteUserKey($uid, $keyId, $encryptionModuleId) {
- $path = $this->constructUserKeyPath($encryptionModuleId, $keyId, $uid);
- return !$this->view->file_exists($path) || $this->view->unlink($path);
+ try {
+ $path = $this->constructUserKeyPath($encryptionModuleId, $keyId, $uid);
+ return !$this->view->file_exists($path) || $this->view->unlink($path);
+ } catch (NoUserException $e) {
+ // this exception can come from initMountPoints() from setupUserMounts()
+ // for a deleted user.
+ //
+ // It means, that:
+ // - we are not running in alternative storage mode because we don't call
+ // initMountPoints() in that mode
+ // - the keys were in the user's home but since the user was deleted, the
+ // user's home is gone and so are the keys
+ //
+ // So there is nothing to do, just ignore.
+ }
}
/**