Skip to content

Commit

Permalink
feat: Warn about maintenance in EncryptAll command
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <[email protected]>
  • Loading branch information
artonge committed Nov 21, 2024
1 parent 1681283 commit 1f6f644
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions core/Command/Encryption/EncryptAll.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

class EncryptAll extends Command {
protected bool $wasTrashbinEnabled = false;
protected bool $wasMaintenanceModeEnabled = false;

public function __construct(
protected IManager $encryptionManager,
Expand All @@ -33,7 +32,6 @@ public function __construct(
*/
protected function forceMaintenanceAndTrashbin(): void {
$this->wasTrashbinEnabled = (bool)$this->appManager->isEnabledForUser('files_trashbin');
$this->wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance');
$this->config->setSystemValue('maintenance', true);
$this->appManager->disableApp('files_trashbin');
}
Expand All @@ -42,7 +40,7 @@ protected function forceMaintenanceAndTrashbin(): void {
* Reset the maintenance mode and re-enable the trashbin app
*/
protected function resetMaintenanceAndTrashbin(): void {
$this->config->setSystemValue('maintenance', $this->wasMaintenanceModeEnabled);
$this->config->setSystemValue('maintenance', false);
if ($this->wasTrashbinEnabled) {
$this->appManager->enableApp('files_trashbin');
}
Expand Down Expand Up @@ -73,6 +71,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
throw new \Exception('Server side encryption is not enabled');
}

if ($this->config->getSystemValueBool('maintenance')) {
$output->writeln('<error>This command cannot be run with maintenance mode enabled.</error>');
return 0;
}

$output->writeln("\n");
$output->writeln('You are about to encrypt all files stored in your Nextcloud installation.');
$output->writeln('Depending on the number of available files, and their size, this may take quite some time.');
Expand Down

0 comments on commit 1f6f644

Please sign in to comment.