From 7af6b962c4b6d76ac7ac889c4f57b0ef6615ef27 Mon Sep 17 00:00:00 2001 From: Steffen Clemens Date: Sat, 13 May 2023 00:04:25 +0200 Subject: [PATCH] Shallow scanning of specific paths Signed-off-by: Steffen Clemens --- lib/Command/Scan.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/Command/Scan.php b/lib/Command/Scan.php index 5e6972086..5d50a60b6 100644 --- a/lib/Command/Scan.php +++ b/lib/Command/Scan.php @@ -46,6 +46,17 @@ protected function configure() { null, InputOption::VALUE_NONE, 'Scan all the group folders.' + ) + ->addOption( + 'path', + 'p', + InputArgument::OPTIONAL, + 'limit rescan to this path, eg. --path="/shared/media/Music"' + )->addOption( + 'shallow', + null, + InputOption::VALUE_NONE, + 'do not scan folders recursively' ); parent::configure(); } @@ -74,6 +85,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) { @@ -110,7 +129,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));