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
This commit is contained in:
Stephan Orbaugh 2025-11-27 11:46:05 +01:00 committed by GitHub
commit fbff470d4c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View file

@ -278,7 +278,7 @@ class EncryptAll {
$this->writePasswordsToFile($newPasswords);
$this->output->writeln('');
$question = new ConfirmationQuestion('Do you want to send the passwords directly to the users by mail? (y/n) ', false);
$question = new ConfirmationQuestion('Do you want to send the passwords directly to the users by mail? (y/n) ', true);
if ($this->questionHelper->ask($this->input, $this->output, $question)) {
$this->sendPasswordsByMail();
}

View file

@ -58,8 +58,11 @@ class EncryptAll extends Command {
);
}
/**
* @throws \Exception
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
if (!$input->isInteractive()) {
if (!$input->isInteractive() && !$input->getOption('no-interaction')) {
$output->writeln('Invalid TTY.');
$output->writeln('If you are trying to execute the command in a Docker ');
$output->writeln("container, do not forget to execute 'docker exec' with");
@ -83,8 +86,9 @@ class EncryptAll extends Command {
$output->writeln('Please ensure that no user accesses their files during this time!');
$output->writeln('Note: The encryption module you use determines which files get encrypted.');
$output->writeln('');
$question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', false);
$question = new ConfirmationQuestion('Do you really want to continue? (y/n) ', true);
if ($this->questionHelper->ask($input, $output, $question)) {
//run encryption with the answer yes in interactive mode
$this->forceMaintenanceAndTrashbin();
try {
@ -98,6 +102,7 @@ class EncryptAll extends Command {
$this->resetMaintenanceAndTrashbin();
return self::SUCCESS;
}
//abort on no in interactive mode
$output->writeln('aborted');
return self::FAILURE;
}