summaryrefslogtreecommitdiffstats
path: root/apps/encryption/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-07-16 14:03:21 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-07-16 14:03:21 +0200
commitd6f02eb703ec69b98f8fecf3ded8bf9f1556cb06 (patch)
tree4f1a19c547425d3b405d9417d0d30e3985a29ade /apps/encryption/lib
parentbfb90d10edfc863213522c704f7d0b8bad8c8646 (diff)
parent1e284b15ff07b7a90067c5166ee7f85547095a34 (diff)
downloadnextcloud-server-d6f02eb703ec69b98f8fecf3ded8bf9f1556cb06.tar.gz
nextcloud-server-d6f02eb703ec69b98f8fecf3ded8bf9f1556cb06.zip
Merge pull request #17500 from owncloud/encryption_migration_improvements
Only clean up if migration finished succesfully
Diffstat (limited to 'apps/encryption/lib')
-rw-r--r--apps/encryption/lib/keymanager.php25
-rw-r--r--apps/encryption/lib/migration.php2
2 files changed, 22 insertions, 5 deletions
diff --git a/apps/encryption/lib/keymanager.php b/apps/encryption/lib/keymanager.php
index 05d23873482..8c8c1f8fd78 100644
--- a/apps/encryption/lib/keymanager.php
+++ b/apps/encryption/lib/keymanager.php
@@ -406,19 +406,36 @@ class KeyManager {
}
/**
- * @param $userId
+ * check if user has a private and a public key
+ *
+ * @param string $userId
* @return bool
+ * @throws PrivateKeyMissingException
+ * @throws PublicKeyMissingException
*/
public function userHasKeys($userId) {
+ $privateKey = $publicKey = true;
+
try {
$this->getPrivateKey($userId);
- $this->getPublicKey($userId);
} catch (PrivateKeyMissingException $e) {
- return false;
+ $privateKey = false;
+ $exception = $e;
+ }
+ try {
+ $this->getPublicKey($userId);
} catch (PublicKeyMissingException $e) {
+ $publicKey = false;
+ $exception = $e;
+ }
+
+ if ($privateKey && $publicKey) {
+ return true;
+ } elseif (!$privateKey && !$publicKey) {
return false;
+ } else {
+ throw $exception;
}
- return true;
}
/**
diff --git a/apps/encryption/lib/migration.php b/apps/encryption/lib/migration.php
index b5d5dc26568..26e2a143f69 100644
--- a/apps/encryption/lib/migration.php
+++ b/apps/encryption/lib/migration.php
@@ -50,7 +50,7 @@ class Migration {
$this->config = $config;
}
- public function __destruct() {
+ public function finalCleanUp() {
$this->view->deleteAll('files_encryption/public_keys');
$this->updateFileCache();
$this->config->deleteAppValue('files_encryption', 'installed_version');