Skip to content

Commit

Permalink
Merge pull request #2232 from steffenclemens/feature/shallow-scanning
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv authored Aug 28, 2024
2 parents 6b756e4 + 0424c8d commit 8d02101
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/Command/Scan.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ protected function configure() {
null,
InputOption::VALUE_NONE,
'Scan all the group folders.'
)
->addOption(
'path',
'p',
InputOption::VALUE_REQUIRED,
'Limit rescan to this path, eg. --path="/shared/media/Music".'
)->addOption(
'shallow',
null,
InputOption::VALUE_NONE,
'Do not scan folders recursively.'
);
parent::configure();
}
Expand Down Expand Up @@ -59,6 +70,14 @@ protected function execute(InputInterface $input, OutputInterface $output) {
$folders = [$folder['id'] => $folder];
}

$inputPath = $input->getOption('path');
if ($inputPath) {
$inputPath = '/' . trim($inputPath, '/');
} else {
$inputPath = '';
}
$recursive = !$input->getOption('shallow');

$duration = 0;
$stats = [];
foreach ($folders as $folder) {
Expand Down Expand Up @@ -95,7 +114,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
$start = microtime(true);

$scanner->setUseTransactions(false);
$scanner->scan('');
$scanner->scan($inputPath, $recursive);

$end = microtime(true);
$statsRow[3] = date('H:i:s', (int)($end - $start));
Expand Down

0 comments on commit 8d02101

Please sign in to comment.