diff options
author | Liam Dennehy <liam@wiemax.net> | 2018-06-28 22:31:27 +0200 |
---|---|---|
committer | Liam Dennehy <liam@wiemax.net> | 2018-06-28 22:31:27 +0200 |
commit | 68e41a3aae803e46be433b372deab16e9b155279 (patch) | |
tree | e24a5bcbe00b650b1f7f1e631c70b1751be81581 /apps | |
parent | 6bc3d3781d9003b9bcdaa47bbe00674fbf272c29 (diff) | |
download | nextcloud-server-68e41a3aae803e46be433b372deab16e9b155279.tar.gz nextcloud-server-68e41a3aae803e46be433b372deab16e9b155279.zip |
trashbin:cleanup exceptions for invalid options
* throw on no parameters provided
* throw on --all-users and userid provided
Signed-off-by: Liam Dennehy <liam@wiemax.net>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_trashbin/lib/Command/CleanUp.php | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/apps/files_trashbin/lib/Command/CleanUp.php b/apps/files_trashbin/lib/Command/CleanUp.php index d1931b6b3e1..d2f8f72be8b 100644 --- a/apps/files_trashbin/lib/Command/CleanUp.php +++ b/apps/files_trashbin/lib/Command/CleanUp.php @@ -32,6 +32,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Exception\InvalidOptionException; class CleanUp extends Command { @@ -75,10 +76,9 @@ class CleanUp extends Command { protected function execute(InputInterface $input, OutputInterface $output) { $users = $input->getArgument('user_id'); - if (!empty($users)) { - if ($input->getOption('all-users')) { - $output->writeln('Option --all-users supplied along with users, restricting to supplied users'); - } + if ((!empty($users)) and ($input->getOption('all-users'))) { + throw new InvalidOptionException('Either specify a user_id or --all-users'); + } elseif (!empty($users)) { foreach ($users as $user) { if ($this->userManager->userExists($user)) { $output->writeln("Remove deleted files of <info>$user</info>"); @@ -106,6 +106,8 @@ class CleanUp extends Command { $offset += $limit; } while (count($users) >= $limit); } + } else { + throw new InvalidOptionException('Either specify a user_id or --all-users'); } } |