]> source.dussan.org Git - nextcloud-server.git/commitdiff
don't block login forever if we are stuck in the middle of the initial encryption
authorBjoern Schiessle <schiessle@owncloud.com>
Tue, 11 Feb 2014 11:44:06 +0000 (12:44 +0100)
committerBjoern Schiessle <schiessle@owncloud.com>
Mon, 17 Feb 2014 09:03:57 +0000 (10:03 +0100)
apps/files_encryption/ajax/getMigrationStatus.php
apps/files_encryption/appinfo/app.php
apps/files_encryption/hooks/hooks.php
apps/files_encryption/js/detect-migration.js
apps/files_encryption/js/encryption.js [new file with mode: 0644]

index 17469a1af0c2e7979306d8008a343bb99c8bba2a..7c9e0dcc51c51d7ecc54bfda8879b806da44be09 100644 (file)
@@ -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)));
index fd9aa429b01622fee7c1aa719c2bd5c7c66aa711..21de421c1956efebd98a391bbf3db4dd6cc36aba 100644 (file)
@@ -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)) {
index 1eb5f4c41e47ec9ec16acdce9791d063ab656954..50f322ddef4c2bca624cc730245bd62389f91d8d 100644 (file)
@@ -85,10 +85,9 @@ class Hooks {
                        $ready = $util->beginMigration();\r
                } elseif ($migrationStatus === Util::MIGRATION_IN_PROGRESS) {\r
                        // refuse login as long as the initial encryption is running\r
-                       while ($migrationStatus === Util::MIGRATION_IN_PROGRESS) {\r
-                               sleep(60);\r
-                               $migrationStatus = $util->getMigrationStatus();\r
-                       }\r
+                       sleep(5);\r
+                       \OCP\User::logout();\r
+                       return false;\r
                }\r
 \r
                // If migration not yet done\r
index 301e77f24f7e88b38ca1678b437cb316432a1573..f5627edf4e4d22a6c5bd39a49a0bc80cd65039fb 100644 (file)
@@ -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 (file)
index 0000000..65ffabe
--- /dev/null
@@ -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,
+};