aboutsummaryrefslogtreecommitdiffstats
path: root/core/Command/Encryption/DecryptAll.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/Command/Encryption/DecryptAll.php')
-rw-r--r--core/Command/Encryption/DecryptAll.php100
1 files changed, 22 insertions, 78 deletions
diff --git a/core/Command/Encryption/DecryptAll.php b/core/Command/Encryption/DecryptAll.php
index 7382c254723..92e2ba787e2 100644
--- a/core/Command/Encryption/DecryptAll.php
+++ b/core/Command/Encryption/DecryptAll.php
@@ -1,32 +1,9 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Björn Schießle <bjoern@schiessle.org>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author davitol <dtoledo@solidgear.es>
- * @author Evgeny Golyshev <eugulixes@gmail.com>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Marius Blüm <marius@lineone.io>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Ruben Homs <ruben@homs.codes>
- * @author Sergio Bertolín <sbertolin@solidgear.es>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OC\Core\Command\Encryption;
@@ -41,55 +18,23 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;
class DecryptAll extends Command {
+ protected bool $wasTrashbinEnabled = false;
+ protected bool $wasMaintenanceModeEnabled = false;
- /** @var IManager */
- protected $encryptionManager;
-
- /** @var IAppManager */
- protected $appManager;
-
- /** @var IConfig */
- protected $config;
-
- /** @var QuestionHelper */
- protected $questionHelper;
-
- /** @var bool */
- protected $wasTrashbinEnabled;
-
- /** @var bool */
- protected $wasMaintenanceModeEnabled;
-
- /** @var \OC\Encryption\DecryptAll */
- protected $decryptAll;
-
- /**
- * @param IManager $encryptionManager
- * @param IAppManager $appManager
- * @param IConfig $config
- * @param \OC\Encryption\DecryptAll $decryptAll
- * @param QuestionHelper $questionHelper
- */
public function __construct(
- IManager $encryptionManager,
- IAppManager $appManager,
- IConfig $config,
- \OC\Encryption\DecryptAll $decryptAll,
- QuestionHelper $questionHelper
+ protected IManager $encryptionManager,
+ protected IAppManager $appManager,
+ protected IConfig $config,
+ protected \OC\Encryption\DecryptAll $decryptAll,
+ protected QuestionHelper $questionHelper,
) {
parent::__construct();
-
- $this->appManager = $appManager;
- $this->encryptionManager = $encryptionManager;
- $this->config = $config;
- $this->decryptAll = $decryptAll;
- $this->questionHelper = $questionHelper;
}
/**
* Set maintenance mode and disable the trashbin app
*/
- protected function forceMaintenanceAndTrashbin() {
+ protected function forceMaintenanceAndTrashbin(): void {
$this->wasTrashbinEnabled = $this->appManager->isEnabledForUser('files_trashbin');
$this->wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance');
$this->config->setSystemValue('maintenance', true);
@@ -99,7 +44,7 @@ class DecryptAll extends Command {
/**
* Reset the maintenance mode and re-enable the trashbin app
*/
- protected function resetMaintenanceAndTrashbin() {
+ protected function resetMaintenanceAndTrashbin(): void {
$this->config->setSystemValue('maintenance', $this->wasMaintenanceModeEnabled);
if ($this->wasTrashbinEnabled) {
$this->appManager->enableApp('files_trashbin');
@@ -136,10 +81,10 @@ class DecryptAll extends Command {
$isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false);
if ($isMaintenanceModeEnabled) {
- $output->writeln("Maintenance mode must be disabled when starting decryption,");
- $output->writeln("in order to load the relevant encryption modules correctly.");
- $output->writeln("Your instance will automatically be put to maintenance mode");
- $output->writeln("during the actual decryption of the files.");
+ $output->writeln('Maintenance mode must be disabled when starting decryption,');
+ $output->writeln('in order to load the relevant encryption modules correctly.');
+ $output->writeln('Your instance will automatically be put to maintenance mode');
+ $output->writeln('during the actual decryption of the files.');
return 1;
}
@@ -181,13 +126,12 @@ class DecryptAll extends Command {
}
$this->resetMaintenanceAndTrashbin();
return 0;
- } else {
- $output->write('Enable server side encryption... ');
- $this->config->setAppValue('core', 'encryption_enabled', 'yes');
- $output->writeln('done.');
- $output->writeln('aborted');
- return 1;
}
+ $output->write('Enable server side encryption... ');
+ $this->config->setAppValue('core', 'encryption_enabled', 'yes');
+ $output->writeln('done.');
+ $output->writeln('aborted');
+ return 1;
} catch (\Exception $e) {
// enable server side encryption again if something went wrong
$this->config->setAppValue('core', 'encryption_enabled', 'yes');