aboutsummaryrefslogtreecommitdiffstats
path: root/apps/encryption/lib/Command/FixEncryptedVersion.php
diff options
context:
space:
mode:
authorFaraz Samapoor <fsa@adlas.at>2023-08-03 14:36:40 +0330
committerJohn Molakvoæ <skjnldsv@users.noreply.github.com>2024-08-16 09:33:16 +0200
commitfc8b886295caf898fd563d2bf54e6233615602d7 (patch)
treec50d92f99fe45072914e561b88972a55ec30a44a /apps/encryption/lib/Command/FixEncryptedVersion.php
parentf4f7c757d45cdcb8d9dc170249a09bc22cd2a994 (diff)
downloadnextcloud-server-fc8b886295caf898fd563d2bf54e6233615602d7.tar.gz
nextcloud-server-fc8b886295caf898fd563d2bf54e6233615602d7.zip
Refactors encryption app commands.
To improve code readability. Signed-off-by: Faraz Samapoor <fsa@adlas.at>
Diffstat (limited to 'apps/encryption/lib/Command/FixEncryptedVersion.php')
-rw-r--r--apps/encryption/lib/Command/FixEncryptedVersion.php20
1 files changed, 9 insertions, 11 deletions
diff --git a/apps/encryption/lib/Command/FixEncryptedVersion.php b/apps/encryption/lib/Command/FixEncryptedVersion.php
index 36f4ee3620e..faeb0348222 100644
--- a/apps/encryption/lib/Command/FixEncryptedVersion.php
+++ b/apps/encryption/lib/Command/FixEncryptedVersion.php
@@ -25,7 +25,7 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class FixEncryptedVersion extends Command {
- private bool $supportLegacy;
+ private bool $supportLegacy = false;
public function __construct(
private IConfig $config,
@@ -35,8 +35,6 @@ class FixEncryptedVersion extends Command {
private Util $util,
private View $view,
) {
- $this->supportLegacy = false;
-
parent::__construct();
}
@@ -69,12 +67,12 @@ class FixEncryptedVersion extends Command {
if ($skipSignatureCheck) {
$output->writeln("<error>Repairing is not possible when \"encryption_skip_signature_check\" is set. Please disable this flag in the configuration.</error>\n");
- return 1;
+ return self::FAILURE;
}
if (!$this->util->isMasterKeyEnabled()) {
$output->writeln("<error>Repairing only works with master key encryption.</error>\n");
- return 1;
+ return self::FAILURE;
}
$user = $input->getArgument('user');
@@ -84,12 +82,12 @@ class FixEncryptedVersion extends Command {
if ($user) {
if ($all) {
$output->writeln("Specifying a user id and --all are mutually exclusive");
- return 1;
+ return self::FAILURE;
}
if ($this->userManager->get($user) === null) {
$output->writeln("<error>User id $user does not exist. Please provide a valid user id</error>");
- return 1;
+ return self::FAILURE;
}
return $this->runForUser($user, $pathOption, $output);
@@ -103,7 +101,7 @@ class FixEncryptedVersion extends Command {
return $result;
} else {
$output->writeln("Either a user id or --all needs to be provided");
- return 1;
+ return self::FAILURE;
}
}
@@ -122,13 +120,13 @@ class FixEncryptedVersion extends Command {
$this->setupUserFs($user);
if (!$this->view->file_exists($path)) {
$output->writeln("<error>Path \"$path\" does not exist. Please provide a valid path.</error>");
- return 1;
+ return self::FAILURE;
}
if ($this->view->is_file($path)) {
$output->writeln("Verifying the content of file \"$path\"");
$this->verifyFileContent($path, $output);
- return 0;
+ return self::SUCCESS;
}
$directories = [];
$directories[] = $path;
@@ -144,7 +142,7 @@ class FixEncryptedVersion extends Command {
}
}
}
- return 0;
+ return self::SUCCESS;
}
/**