add quiet option, ref #8794
This commit is contained in:
parent
7ef6df04da
commit
3cdaa4094f
|
@ -39,11 +39,17 @@ class Scan extends Command {
|
|||
)
|
||||
->addOption(
|
||||
'path',
|
||||
null,
|
||||
'p',
|
||||
InputArgument::OPTIONAL,
|
||||
'limit rescan to this path, eg. --path="files/Music"',
|
||||
''
|
||||
)
|
||||
->addOption(
|
||||
'quiet',
|
||||
'q',
|
||||
InputOption::VALUE_NONE,
|
||||
'suppress output'
|
||||
)
|
||||
->addOption(
|
||||
'all',
|
||||
null,
|
||||
|
@ -52,14 +58,16 @@ class Scan extends Command {
|
|||
);
|
||||
}
|
||||
|
||||
protected function scanFiles($user, $path, OutputInterface $output) {
|
||||
protected function scanFiles($user, $path, $quiet, OutputInterface $output) {
|
||||
$scanner = new \OC\Files\Utils\Scanner($user, \OC::$server->getDatabaseConnection());
|
||||
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) {
|
||||
$output->writeln("Scanning <info>$path</info>");
|
||||
});
|
||||
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) {
|
||||
$output->writeln("Scanning <info>$path</info>");
|
||||
});
|
||||
if (!$quiet) {
|
||||
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) {
|
||||
$output->writeln("Scanning <info>$path</info>");
|
||||
});
|
||||
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) {
|
||||
$output->writeln("Scanning <info>$path</info>");
|
||||
});
|
||||
}
|
||||
try {
|
||||
$scanner->scan($path);
|
||||
} catch (ForbiddenException $e) {
|
||||
|
@ -75,6 +83,7 @@ class Scan extends Command {
|
|||
$users = $input->getArgument('user_id');
|
||||
}
|
||||
$path = trim($input->getOption('path'), '/');
|
||||
$quiet = $input->getOption('quiet');
|
||||
|
||||
if (count($users) === 0) {
|
||||
$output->writeln("<error>Please specify the user id to scan or \"--all\" to scan for all users</error>");
|
||||
|
@ -86,7 +95,7 @@ class Scan extends Command {
|
|||
$user = $user->getUID();
|
||||
}
|
||||
if ($this->userManager->userExists($user)) {
|
||||
$this->scanFiles($user, $path, $output);
|
||||
$this->scanFiles($user, $path, $quiet, $output);
|
||||
} else {
|
||||
$output->writeln("<error>Unknown user $user</error>");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue