diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2023-11-20 22:20:29 -0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-20 22:20:29 -0100 |
commit | ae71ed1e3771107f138112d3037eeca49ea92111 (patch) | |
tree | bda3141bef42dedbd79eac44c50ec3cf9c43dc10 /apps/files | |
parent | 4bc45a7f9cab24378d1cf9937d151cfbd9466e11 (diff) | |
parent | 22d6c8dcd44c239609e905558fbc835f1dcd840c (diff) | |
download | nextcloud-server-ae71ed1e3771107f138112d3037eeca49ea92111.tar.gz nextcloud-server-ae71ed1e3771107f138112d3037eeca49ea92111.zip |
Merge pull request #41601 from nextcloud/enh/noid/named-metadata-event
add named metadata event
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/lib/Command/Scan.php | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/apps/files/lib/Command/Scan.php b/apps/files/lib/Command/Scan.php index 7cdaf75e9bc..a78b6cbe8b1 100644 --- a/apps/files/lib/Command/Scan.php +++ b/apps/files/lib/Command/Scan.php @@ -96,8 +96,9 @@ class Scan extends Base { ->addOption( 'generate-metadata', null, - InputOption::VALUE_NONE, - 'Generate metadata for all scanned files' + InputOption::VALUE_OPTIONAL, + 'Generate metadata for all scanned files; if specified only generate for named value', + '' ) ->addOption( 'all', @@ -122,7 +123,7 @@ class Scan extends Base { ); } - protected function scanFiles(string $user, string $path, bool $scanMetadata, OutputInterface $output, bool $backgroundScan = false, bool $recursive = true, bool $homeOnly = false): void { + protected function scanFiles(string $user, string $path, ?string $scanMetadata, OutputInterface $output, bool $backgroundScan = false, bool $recursive = true, bool $homeOnly = false): void { $connection = $this->reconnectToDatabase($output); $scanner = new \OC\Files\Utils\Scanner( $user, @@ -136,11 +137,12 @@ class Scan extends Base { $output->writeln("\tFile\t<info>$path</info>", OutputInterface::VERBOSITY_VERBOSE); ++$this->filesCounter; $this->abortIfInterrupted(); - if ($scanMetadata) { + if ($scanMetadata !== null) { $node = $this->rootFolder->get($path); $this->filesMetadataManager->refreshMetadata( $node, - IFilesMetadataManager::PROCESS_LIVE | IFilesMetadataManager::PROCESS_BACKGROUND + ($scanMetadata !== '') ? IFilesMetadataManager::PROCESS_NAMED : IFilesMetadataManager::PROCESS_LIVE | IFilesMetadataManager::PROCESS_BACKGROUND, + $scanMetadata ); } }); @@ -221,6 +223,12 @@ class Scan extends Base { $this->initTools($output); + // getOption() logic on VALUE_OPTIONAL + $metadata = null; // null if --generate-metadata is not set, empty if option have no value, value if set + if ($input->getOption('generate-metadata') !== '') { + $metadata = $input->getOption('generate-metadata') ?? ''; + } + $user_count = 0; foreach ($users as $user) { if (is_object($user)) { @@ -230,7 +238,7 @@ class Scan extends Base { ++$user_count; if ($this->userManager->userExists($user)) { $output->writeln("Starting scan for user $user_count out of $users_total ($user)"); - $this->scanFiles($user, $path, $input->getOption('generate-metadata'), $output, $input->getOption('unscanned'), !$input->getOption('shallow'), $input->getOption('home-only')); + $this->scanFiles($user, $path, $metadata, $output, $input->getOption('unscanned'), !$input->getOption('shallow'), $input->getOption('home-only')); $output->writeln('', OutputInterface::VERBOSITY_VERBOSE); } else { $output->writeln("<error>Unknown user $user_count $user</error>"); |