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
+15
View File
@@ -0,0 +1,15 @@
"""Confirms every FC-2a task module imports cleanly and registers with Celery."""
from backend.app.celery_app import celery
def test_scan_task_registered():
assert "backend.app.tasks.scan.scan_directory" in celery.tasks
def test_import_media_file_registered():
assert "backend.app.tasks.import_file.import_media_file" in celery.tasks
def test_generate_thumbnail_registered():
assert "backend.app.tasks.thumbnail.generate_thumbnail" in celery.tasks