[s3] sync by query (which might be an ID range) rather than by ID range

This commit is contained in:
Shish 2024-03-17 21:52:47 +00:00 committed by Shish
parent fc34513b7d
commit 74ad1bf86d

View file

@ -99,14 +99,11 @@ class S3 extends Extension
return Command::SUCCESS; return Command::SUCCESS;
}); });
$event->app->register('s3:sync') $event->app->register('s3:sync')
->addArgument('start', InputArgument::REQUIRED) ->addArgument('query', InputArgument::REQUIRED)
->addArgument('end', InputArgument::REQUIRED) ->setDescription('Search for some images, and sync them to s3')
->setDescription('Sync a range of images to S3')
->setCode(function (InputInterface $input, OutputInterface $output): int { ->setCode(function (InputInterface $input, OutputInterface $output): int {
$start = (int)$input->getArgument('start'); $query = Tag::explode($input->getArgument('query'));
$end = (int)$input->getArgument('end'); foreach(Search::find_images_iterable(tags: $query) as $image) {
$output->writeln("Syncing range: $start - $end");
foreach(Search::find_images_iterable(tags: ["order=id", "id>=$start", "id<=$end"]) as $image) {
if($this->sync_post($image)) { if($this->sync_post($image)) {
print("{$image->id}: {$image->hash}\n"); print("{$image->id}: {$image->hash}\n");
} else { } else {