feat(fc2a): add Celery tasks — scan_directory, import_media_file, generate_thumbnail

scan_directory walks ImportSettings.import_scan_path, creates an
ImportBatch, enumerates supported files into ImportTasks, and enqueues
import_media_file per task. import_media_file moves the task through
its state machine (pending → queued → processing → complete/skipped/failed),
updates ImportBatch counters atomically (UPDATE ... SET col = col + 1),
enqueues a thumbnail task on success, and marks the batch complete when
the last task drains.

generate_thumbnail runs on its own queue (thumbnail) so big imports
don't starve thumbnail throughput; failure here is logged and does not
fail the import.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-14 12:08:37 -04:00
parent f38a1d48c5
commit d3bb8c509a
5 changed files with 272 additions and 1 deletions
+7 -1
View File
@@ -22,7 +22,13 @@ def make_celery() -> Celery:
"fabledcurator",
broker=cfg.celery_broker_url,
backend=cfg.celery_result_backend,
include=["backend.app.tasks.smoke"], # FC-2/FC-3 extend this list
include=[
"backend.app.tasks.smoke",
"backend.app.tasks.scan",
"backend.app.tasks.import_file",
"backend.app.tasks.thumbnail",
"backend.app.tasks.maintenance",
],
)
app.conf.update(
task_default_queue="default",