Skip to content

Commit

Permalink
Use the tag manager to skip tagged files
Browse files Browse the repository at this point in the history
Signed-off-by: Niels <niels.muendler@inf.ethz.ch>
  • Loading branch information
nielstron committed Sep 10, 2024
1 parent cfc6194 commit 8cfc836
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/Command/Classify.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,6 +31,7 @@ class Classify extends Command {

public function __construct(
private StorageService $storageService,
private TagManager $tagManager,
private Logger $logger,
ImagenetClassifier $imagenet,
ClusteringFaceClassifier $faces,
Expand Down Expand Up @@ -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']);

Expand All @@ -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']);
Expand Down

0 comments on commit 8cfc836

Please sign in to comment.