aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_versions/lib/Command/CleanUp.php
diff options
context:
space:
mode:
authorFaraz Samapoor <fsa@adlas.at>2023-08-03 16:42:56 +0330
committerFaraz Samapoor <fsa@adlas.at>2023-08-03 16:42:56 +0330
commit90652fd30fcbe620d1b1bf87899eeae6f6c7c657 (patch)
treeeb753d8cb166e9452d7ac4c92549116dddb60462 /apps/files_versions/lib/Command/CleanUp.php
parentab797062533bfac412eb9300c2ae01e380609b45 (diff)
downloadnextcloud-server-90652fd30fcbe620d1b1bf87899eeae6f6c7c657.tar.gz
nextcloud-server-90652fd30fcbe620d1b1bf87899eeae6f6c7c657.zip
Uses early returns.
To improve code readability. Signed-off-by: Faraz Samapoor <fsa@adlas.at>
Diffstat (limited to 'apps/files_versions/lib/Command/CleanUp.php')
-rw-r--r--apps/files_versions/lib/Command/CleanUp.php48
1 files changed, 25 insertions, 23 deletions
diff --git a/apps/files_versions/lib/Command/CleanUp.php b/apps/files_versions/lib/Command/CleanUp.php
index 26a1c57ec74..2a19c57710e 100644
--- a/apps/files_versions/lib/Command/CleanUp.php
+++ b/apps/files_versions/lib/Command/CleanUp.php
@@ -75,37 +75,39 @@ class CleanUp extends Command {
if (!empty($users)) {
foreach ($users as $user) {
- if ($this->userManager->userExists($user)) {
- $output->writeln("Delete versions of <info>$user</info>");
- $this->deleteVersions($user, $path);
- } else {
+ if (!$this->userManager->userExists($user)) {
$output->writeln("<error>Unknown user $user</error>");
return self::FAILURE;
}
+
+ $output->writeln("Delete versions of <info>$user</info>");
+ $this->deleteVersions($user, $path);
}
- } else {
- $output->writeln('Delete all versions');
- foreach ($this->userManager->getBackends() as $backend) {
- $name = get_class($backend);
+ return self::SUCCESS;
+ }
- if ($backend instanceof IUserBackend) {
- $name = $backend->getBackendName();
- }
+ $output->writeln('Delete all versions');
+ foreach ($this->userManager->getBackends() as $backend) {
+ $name = get_class($backend);
- $output->writeln("Delete versions for users on backend <info>$name</info>");
-
- $limit = 500;
- $offset = 0;
- do {
- $users = $backend->getUsers('', $limit, $offset);
- foreach ($users as $user) {
- $output->writeln(" <info>$user</info>");
- $this->deleteVersions($user);
- }
- $offset += $limit;
- } while (count($users) >= $limit);
+ if ($backend instanceof IUserBackend) {
+ $name = $backend->getBackendName();
}
+
+ $output->writeln("Delete versions for users on backend <info>$name</info>");
+
+ $limit = 500;
+ $offset = 0;
+ do {
+ $users = $backend->getUsers('', $limit, $offset);
+ foreach ($users as $user) {
+ $output->writeln(" <info>$user</info>");
+ $this->deleteVersions($user);
+ }
+ $offset += $limit;
+ } while (count($users) >= $limit);
}
+
return self::SUCCESS;
}