aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/hooks
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-02-10 16:43:04 +0100
committerBjoern Schiessle <schiessle@owncloud.com>2014-02-17 09:58:46 +0100
commit2ab062193a355e87946f310c992d5449eaf558cc (patch)
treedb8136c832bc7e58b3b57428e1148565f78f30a3 /apps/files_encryption/hooks
parent750ffa82317a6538384a9680d3fe5bc4b0395c70 (diff)
downloadnextcloud-server-2ab062193a355e87946f310c992d5449eaf558cc.tar.gz
nextcloud-server-2ab062193a355e87946f310c992d5449eaf558cc.zip
catch errors during initial encryption
Diffstat (limited to 'apps/files_encryption/hooks')
-rw-r--r--apps/files_encryption/hooks/hooks.php22
1 files changed, 14 insertions, 8 deletions
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php
index 83abf3ba9de..1eb5f4c41e4 100644
--- a/apps/files_encryption/hooks/hooks.php
+++ b/apps/files_encryption/hooks/hooks.php
@@ -109,21 +109,27 @@ class Hooks {
}
- // Encrypt existing user files:
- if (
- $util->encryptAll('/' . $params['uid'] . '/' . 'files', $session->getLegacyKey(), $params['password'])
- ) {
+ // Encrypt existing user files
+ try {
+ $result = $util->encryptAll('/' . $params['uid'] . '/' . 'files', $session->getLegacyKey(), $params['password']);
+ } catch (\Exception $ex) {
+ \OCP\Util::writeLog('Encryption library', 'Initial encryption failed! Error: ' . $ex->getMessage(), \OCP\Util::FATAL);
+ $util->resetMigrationStatus();
+ \OCP\User::logout();
+ $result = false;
+ }
+
+ if ($result) {
\OC_Log::write(
'Encryption library', 'Encryption of existing files belonging to "' . $params['uid'] . '" completed'
, \OC_Log::INFO
);
- }
-
- // Register successful migration in DB
- $util->finishMigration();
+ // Register successful migration in DB
+ $util->finishMigration();
+ }
}
return true;