aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/lib/Command/Size.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_trashbin/lib/Command/Size.php')
-rw-r--r--apps/files_trashbin/lib/Command/Size.php39
1 files changed, 16 insertions, 23 deletions
diff --git a/apps/files_trashbin/lib/Command/Size.php b/apps/files_trashbin/lib/Command/Size.php
index 6d0e745bf5c..9c19d4d92b3 100644
--- a/apps/files_trashbin/lib/Command/Size.php
+++ b/apps/files_trashbin/lib/Command/Size.php
@@ -13,26 +13,19 @@ use OCP\Command\IBus;
use OCP\IConfig;
use OCP\IUser;
use OCP\IUserManager;
+use OCP\Util;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class Size extends Base {
- private $config;
- private $userManager;
- private $commandBus;
-
public function __construct(
- IConfig $config,
- IUserManager $userManager,
- IBus $commandBus
+ private IConfig $config,
+ private IUserManager $userManager,
+ private IBus $commandBus,
) {
parent::__construct();
-
- $this->config = $config;
- $this->userManager = $userManager;
- $this->commandBus = $commandBus;
}
protected function configure() {
@@ -53,9 +46,9 @@ class Size extends Base {
$size = $input->getArgument('size');
if ($size) {
- $parsedSize = \OC_Helper::computerFileSize($size);
+ $parsedSize = Util::computerFileSize($size);
if ($parsedSize === false) {
- $output->writeln("<error>Failed to parse input size</error>");
+ $output->writeln('<error>Failed to parse input size</error>');
return -1;
}
if ($user) {
@@ -63,8 +56,8 @@ class Size extends Base {
$this->commandBus->push(new Expire($user));
} else {
$this->config->setAppValue('files_trashbin', 'trashbin_size', (string)$parsedSize);
- $output->writeln("<info>Warning: changing the default trashbin size will automatically trigger cleanup of existing trashbins,</info>");
- $output->writeln("<info>a users trashbin can exceed the configured size until they move a new file to the trashbin.</info>");
+ $output->writeln('<info>Warning: changing the default trashbin size will automatically trigger cleanup of existing trashbins,</info>');
+ $output->writeln('<info>a users trashbin can exceed the configured size until they move a new file to the trashbin.</info>');
}
} else {
$this->printTrashbinSize($input, $output, $user);
@@ -76,9 +69,9 @@ class Size extends Base {
private function printTrashbinSize(InputInterface $input, OutputInterface $output, ?string $user) {
$globalSize = (int)$this->config->getAppValue('files_trashbin', 'trashbin_size', '-1');
if ($globalSize < 0) {
- $globalHumanSize = "default (50% of available space)";
+ $globalHumanSize = 'default (50% of available space)';
} else {
- $globalHumanSize = \OC_Helper::humanFileSize($globalSize);
+ $globalHumanSize = Util::humanFileSize($globalSize);
}
if ($user) {
@@ -87,7 +80,7 @@ class Size extends Base {
if ($userSize < 0) {
$userHumanSize = ($globalSize < 0) ? $globalHumanSize : "default($globalHumanSize)";
} else {
- $userHumanSize = \OC_Helper::humanFileSize($userSize);
+ $userHumanSize = Util::humanFileSize($userSize);
}
if ($input->getOption('output') == self::OUTPUT_FORMAT_PLAIN) {
@@ -103,21 +96,21 @@ class Size extends Base {
}
} else {
$users = [];
- $this->userManager->callForSeenUsers(function (IUser $user) use (&$users) {
+ $this->userManager->callForSeenUsers(function (IUser $user) use (&$users): void {
$users[] = $user->getUID();
});
$userValues = $this->config->getUserValueForUsers('files_trashbin', 'trashbin_size', $users);
if ($input->getOption('output') == self::OUTPUT_FORMAT_PLAIN) {
$output->writeln("Default size: $globalHumanSize");
- $output->writeln("");
+ $output->writeln('');
if (count($userValues)) {
- $output->writeln("Per-user sizes:");
+ $output->writeln('Per-user sizes:');
$this->writeArrayInOutputFormat($input, $output, array_map(function ($size) {
- return \OC_Helper::humanFileSize($size);
+ return Util::humanFileSize($size);
}, $userValues));
} else {
- $output->writeln("No per-user sizes configured");
+ $output->writeln('No per-user sizes configured');
}
} else {
$globalValue = ($globalSize < 0) ? 'default' : $globalSize;