summaryrefslogtreecommitdiffstats
path: root/lib/private/encryption
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-04-09 10:28:02 +0200
committerJoas Schilling <nickvergessen@owncloud.com>2015-04-09 10:28:02 +0200
commit45575d0135368169af71379a39c8914e7a1cf524 (patch)
tree4c38adac97c64f85ddc1cb8d4022693b6cf5a4fc /lib/private/encryption
parent56f1ffe820383ac82c208552213848c6a8deec6d (diff)
downloadnextcloud-server-45575d0135368169af71379a39c8914e7a1cf524.tar.gz
nextcloud-server-45575d0135368169af71379a39c8914e7a1cf524.zip
Check if the key exists, before trying to delete it
Diffstat (limited to 'lib/private/encryption')
-rw-r--r--lib/private/encryption/keys/storage.php17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/private/encryption/keys/storage.php b/lib/private/encryption/keys/storage.php
index 40bd3056b1a..9d978193130 100644
--- a/lib/private/encryption/keys/storage.php
+++ b/lib/private/encryption/keys/storage.php
@@ -140,11 +140,11 @@ class Storage implements \OCP\Encryption\Keys\IStorage {
* @param string $uid ID if the user for whom we want to delete the key
* @param string $keyId id of the key
*
- * @return boolean
+ * @return boolean False when the key could not be deleted
*/
public function deleteUserKey($uid, $keyId) {
$path = $this->constructUserKeyPath($keyId, $uid);
- return $this->view->unlink($path);
+ return !$this->view->file_exists($path) || $this->view->unlink($path);
}
/**
@@ -153,22 +153,23 @@ class Storage implements \OCP\Encryption\Keys\IStorage {
* @param string $path path to file
* @param string $keyId id of the key
*
- * @return boolean
+ * @return boolean False when the key could not be deleted
*/
public function deleteFileKey($path, $keyId) {
$keyDir = $this->getFileKeyDir($path);
- return $this->view->unlink($keyDir . $keyId);
+ return !$this->view->file_exists($keyDir . $keyId) || $this->view->unlink($keyDir . $keyId);
}
/**
* delete all file keys for a given file
*
* @param string $path to the file
- * @return boolean
+ * @return boolean False when the key could not be deleted
*/
public function deleteAllFileKeys($path) {
$keyDir = $this->getFileKeyDir($path);
- return $this->view->deleteAll(dirname($keyDir));
+ $path = dirname($keyDir);
+ return !$this->view->file_exists($path) || $this->view->deleteAll($path);
}
/**
@@ -177,11 +178,11 @@ class Storage implements \OCP\Encryption\Keys\IStorage {
*
* @param string $keyId id of the key
*
- * @return boolean
+ * @return boolean False when the key could not be deleted
*/
public function deleteSystemUserKey($keyId) {
$path = $this->constructUserKeyPath($keyId);
- return $this->view->unlink($path);
+ return !$this->view->file_exists($path) || $this->view->unlink($path);
}