Skip to content

Commit fbff470

Browse files
authored
Merge pull request #56419 from nextcloud/fix/provide-non-interactive-mode-to-run-encryption
fix: support -n option to encrypt-all command to allow to run in non-interactive mode
2 parents 590d839 + d134b23 commit fbff470

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

apps/encryption/lib/Crypto/EncryptAll.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ protected function outputPasswords(): void {
278278
$this->writePasswordsToFile($newPasswords);
279279

280280
$this->output->writeln('');
281-
$question = new ConfirmationQuestion('Do you want to send the passwords directly to the users by mail? (y/n) ', false);
281+
$question = new ConfirmationQuestion('Do you want to send the passwords directly to the users by mail? (y/n) ', true);
282282
if ($this->questionHelper->ask($this->input, $this->output, $question)) {
283283
$this->sendPasswordsByMail();
284284
}

core/Command/Encryption/EncryptAll.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ protected function configure() {
5858
);
5959
}
6060

61+
/**
62+
* @throws \Exception
63+
*/
6164
protected function execute(InputInterface $input, OutputInterface $output): int {
62-
if (!$input->isInteractive()) {
65+
if (!$input->isInteractive() && !$input->getOption('no-interaction')) {
6366
$output->writeln('Invalid TTY.');
6467
$output->writeln('If you are trying to execute the command in a Docker ');
6568
$output->writeln("container, do not forget to execute 'docker exec' with");
@@ -83,8 +86,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8386
$output->writeln('Please ensure that no user accesses their files during this time!');
8487
$output->writeln('Note: The encryption module you use determines which files get encrypted.');
8588
$output->writeln('');
86-
$question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', false);
89+
$question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', true);
8790
if ($this->questionHelper->ask($input, $output, $question)) {
91+
//run encryption with the answer yes in interactive mode
8892
$this->forceMaintenanceAndTrashbin();
8993

9094
try {
@@ -98,6 +102,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
98102
$this->resetMaintenanceAndTrashbin();
99103
return self::SUCCESS;
100104
}
105+
//abort on no in interactive mode
101106
$output->writeln('aborted');
102107
return self::FAILURE;
103108
}

0 commit comments

Comments
 (0)