aboutsummaryrefslogtreecommitdiffstats
path: root/apps/encryption/lib/Command/FixEncryptedVersion.php
diff options
context:
space:
mode:
authorFaraz Samapoor <fsa@adlas.at>2023-08-03 14:50:33 +0330
committerJohn Molakvoæ <skjnldsv@users.noreply.github.com>2024-08-16 09:33:16 +0200
commit6b795da540d50f2ca1e70a284a7367390621b50b (patch)
tree2417c3354de450f08ecd7a440bf0f5c86b098e80 /apps/encryption/lib/Command/FixEncryptedVersion.php
parentfc8b886295caf898fd563d2bf54e6233615602d7 (diff)
downloadnextcloud-server-6b795da540d50f2ca1e70a284a7367390621b50b.tar.gz
nextcloud-server-6b795da540d50f2ca1e70a284a7367390621b50b.zip
Uses early returns.
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.php24
1 files changed, 13 insertions, 11 deletions
diff --git a/apps/encryption/lib/Command/FixEncryptedVersion.php b/apps/encryption/lib/Command/FixEncryptedVersion.php
index faeb0348222..d2764036b39 100644
--- a/apps/encryption/lib/Command/FixEncryptedVersion.php
+++ b/apps/encryption/lib/Command/FixEncryptedVersion.php
@@ -79,6 +79,11 @@ class FixEncryptedVersion extends Command {
$all = $input->getOption('all');
$pathOption = \trim(($input->getOption('path') ?? ''), '/');
+ if (!$user && !$all) {
+ $output->writeln("Either a user id or --all needs to be provided");
+ return self::FAILURE;
+ }
+
if ($user) {
if ($all) {
$output->writeln("Specifying a user id and --all are mutually exclusive");
@@ -91,18 +96,15 @@ class FixEncryptedVersion extends Command {
}
return $this->runForUser($user, $pathOption, $output);
- } elseif ($all) {
- $result = 0;
- $this->userManager->callForSeenUsers(function (IUser $user) use ($pathOption, $output, &$result) {
- $output->writeln("Processing files for " . $user->getUID());
- $result = $this->runForUser($user->getUID(), $pathOption, $output);
- return $result === 0;
- });
- return $result;
- } else {
- $output->writeln("Either a user id or --all needs to be provided");
- return self::FAILURE;
}
+
+ $result = 0;
+ $this->userManager->callForSeenUsers(function (IUser $user) use ($pathOption, $output, &$result) {
+ $output->writeln("Processing files for " . $user->getUID());
+ $result = $this->runForUser($user->getUID(), $pathOption, $output);
+ return $result === 0;
+ });
+ return $result;
}
private function runForUser(string $user, string $pathOption, OutputInterface $output): int {