Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-02-11 15:44:06 +0400
committerBjoern Schiessle <schiessle@owncloud.com>2014-02-17 13:24:04 +0400
commit43738dacfb90562d26b21c1a9f3d0c5d51d759b3 (patch)
treed70855b85b37ae1e3f74a21b5c645f4bb6990630 /apps/files_encryption
parent78b10de7d67aeaa9341fe99ca17e85ee5c113d83 (diff)
don't block login forever if we are stuck in the middle of the initial encryption
Diffstat (limited to 'apps/files_encryption')
-rw-r--r--apps/files_encryption/ajax/getMigrationStatus.php8
-rw-r--r--apps/files_encryption/appinfo/app.php1
-rw-r--r--apps/files_encryption/hooks/hooks.php7
-rw-r--r--apps/files_encryption/js/detect-migration.js6
-rw-r--r--apps/files_encryption/js/encryption.js12
5 files changed, 24 insertions, 10 deletions
diff --git a/apps/files_encryption/ajax/getMigrationStatus.php b/apps/files_encryption/ajax/getMigrationStatus.php
index 17469a1af0c..7c9e0dcc51c 100644
--- a/apps/files_encryption/ajax/getMigrationStatus.php
+++ b/apps/files_encryption/ajax/getMigrationStatus.php
@@ -13,16 +13,14 @@ use OCA\Encryption\Util;
$loginname = isset($_POST['user']) ? $_POST['user'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
-$migrationCompleted = true;
+$migrationStatus = Util::MIGRATION_COMPLETED;
if ($loginname !== '' && $password !== '') {
$username = \OCP\User::checkPassword($loginname, $password);
if ($username) {
$util = new Util(new \OC_FilesystemView('/'), $username);
- if ($util->getMigrationStatus() !== Util::MIGRATION_COMPLETED) {
- $migrationCompleted = false;
- }
+ $migrationStatus = $util->getMigrationStatus();
}
}
-\OCP\JSON::success(array('data' => array('migrationCompleted' => $migrationCompleted)));
+\OCP\JSON::success(array('data' => array('migrationStatus' => $migrationStatus)));
diff --git a/apps/files_encryption/appinfo/app.php b/apps/files_encryption/appinfo/app.php
index fd9aa429b01..21de421c195 100644
--- a/apps/files_encryption/appinfo/app.php
+++ b/apps/files_encryption/appinfo/app.php
@@ -10,6 +10,7 @@ OC::$CLASSPATH['OCA\Encryption\Session'] = 'files_encryption/lib/session.php';
OC::$CLASSPATH['OCA\Encryption\Capabilities'] = 'files_encryption/lib/capabilities.php';
OC::$CLASSPATH['OCA\Encryption\Helper'] = 'files_encryption/lib/helper.php';
+\OCP\Util::addscript('files_encryption', 'encryption');
\OCP\Util::addscript('files_encryption', 'detect-migration');
if (!OC_Config::getValue('maintenance', false)) {
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php
index 1eb5f4c41e4..50f322ddef4 100644
--- a/apps/files_encryption/hooks/hooks.php
+++ b/apps/files_encryption/hooks/hooks.php
@@ -85,10 +85,9 @@ class Hooks {
$ready = $util->beginMigration();
} elseif ($migrationStatus === Util::MIGRATION_IN_PROGRESS) {
// refuse login as long as the initial encryption is running
- while ($migrationStatus === Util::MIGRATION_IN_PROGRESS) {
- sleep(60);
- $migrationStatus = $util->getMigrationStatus();
- }
+ sleep(5);
+ \OCP\User::logout();
+ return false;
}
// If migration not yet done
diff --git a/apps/files_encryption/js/detect-migration.js b/apps/files_encryption/js/detect-migration.js
index 301e77f24f7..f5627edf4e4 100644
--- a/apps/files_encryption/js/detect-migration.js
+++ b/apps/files_encryption/js/detect-migration.js
@@ -17,10 +17,14 @@ $(document).ready(function(){
data: {user: user, password: password},
async: false,
success: function(response) {
- if (response.data.migrationCompleted === false) {
+ if (response.data.migrationStatus === OC.Encryption.MIGRATION_OPEN) {
var message = t('files_encryption', 'Initial encryption started... This can take some time. Please wait.');
$('#messageText').text(message);
$('#message').removeClass('hidden').addClass('update');
+ } else if (response.data.migrationStatus === OC.Encryption.MIGRATION_IN_PROGRESS) {
+ var message = t('files_encryption', 'Initial encryption running... Please try again later.');
+ $('#messageText').text(message);
+ $('#message').removeClass('hidden').addClass('update');
}
}
});
diff --git a/apps/files_encryption/js/encryption.js b/apps/files_encryption/js/encryption.js
new file mode 100644
index 00000000000..65ffabe55e6
--- /dev/null
+++ b/apps/files_encryption/js/encryption.js
@@ -0,0 +1,12 @@
+/**
+ * Copyright (c) 2014
+ * Bjoern Schiessle <schiessle@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or later.
+ * See the COPYING-README file.
+ */
+
+OC.Encryption={
+ MIGRATION_OPEN:0,
+ MIGRATION_COMPLETED:1,
+ MIGRATION_IN_PROGRESS:-1,
+};