From 8cfc83666a6a171e0429cced95298381cff3142b Mon Sep 17 00:00:00 2001 From: Niels Date: Tue, 10 Sep 2024 16:11:04 +0200 Subject: [PATCH] Use the tag manager to skip tagged files Signed-off-by: Niels --- lib/Command/Classify.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/Command/Classify.php b/lib/Command/Classify.php index 035c8926..c98b1542 100644 --- a/lib/Command/Classify.php +++ b/lib/Command/Classify.php @@ -16,6 +16,7 @@ use OCA\Recognize\Service\Logger; use OCA\Recognize\Service\SettingsService; use OCA\Recognize\Service\StorageService; +use OCA\Recognize\Service\TagManager; use OCP\Files\Config\ICachedMountInfo; use OCP\Files\Config\IUserMountCache; use Symfony\Component\Console\Command\Command; @@ -30,6 +31,7 @@ class Classify extends Command { public function __construct( private StorageService $storageService, + private TagManager $tagManager, private Logger $logger, ImagenetClassifier $imagenet, ClusteringFaceClassifier $faces, @@ -79,6 +81,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int MusicnnClassifier::MODEL_NAME, ], fn ($modelName) => $this->settings->getSetting($modelName . '.enabled') === 'true')); + $processedTag = $this->tagManager->getProcessedTag(); + foreach ($this->storageService->getMounts() as $mount) { $this->logger->info('Processing storage ' . $mount['storage_id'] . ' with root ID ' . $mount['override_root']); @@ -102,6 +106,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int foreach ($this->storageService->getFilesInMount($mount['storage_id'], $mount['override_root'], $models, $lastFileId) as $file) { $i++; $lastFileId = $file['fileid']; + // if retry flag is set, skip tagged files + if ($input->getOption('retry')) { + $fileTags = $this->tagManager->getTagsForFiles([$lastFileId]); + // check if processed tag is already in the tags + if (in_array($processedTag, $fileTags)) { + continue; + } + } $queueFile = new QueueFile(); $queueFile->setStorageId($mount['storage_id']); $queueFile->setRootId($mount['root_id']);