Skip to content
Snippets Groups Projects
Commit 3cdaa409 authored by Jörn Friedrich Dreyer's avatar Jörn Friedrich Dreyer
Browse files

add quiet option, ref #8794

parent 7ef6df04
No related branches found
No related tags found
No related merge requests found
......@@ -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>");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment