No site selected

Import Media

Queue cloud-sync handover batches; the background worker consumes them.

About this section: Import MediaQueue cloud-sync handover bundles; the worker imports them in the background.

Purpose

Consume the upstream cloud-sync handover bundles from /mnt/s3-sync/assets/sync/ into the global library (asset, asset_gallery, asset_collection) per Decision 639. The CGI never imports inline; it queues batches into import_job for the background worker (Decision 640).

Flow

  • Scan: walks the mount for .ready sentinels and records new ingest_batch rows.
  • Pre-flight: validates the manifest shape, sentinel pair, and per-item decisions; no library writes.
  • Queue: auto-preflights if needed, then inserts an import_job row. Live progress shows on Import Tasks.
  • Bulk queue: select multiple batches and queue them in one click; the worker drains the queue in priority + FIFO order.

Example

Scan finds 37e428d2-a4f6-4a31-bacf-0c835fb24084.ready. Tick its checkbox (or several at once), click Queue selected. The worker claims the next queued job within seconds and writes job_* events as it progresses.

Consequences

  • The library is site-agnostic. Sites surface library content via asset_site_membership, gallery/collection membership, content allowlists, and access packages.
  • Cancel is allowed only while a job is queued; once running, only systemctl stop gpu-admin-panel-import-worker stops it.
  • Action remove only soft-deletes rows via deleted_at; nothing is hard-deleted.
  • Frosted, blurred, and vivid_blurred derivatives are intentionally not persisted.
Deeper dive

Sourced from gpu-floor/MIGRATION-INTRO.md and the queued-worker decision in DECISION_LOG.md.

Worker contract

A long-running import-worker.pl daemon claims queued jobs using SELECT ... FOR UPDATE SKIP LOCKED (MariaDB 10.6+). It updates heartbeat_at every few items; if a worker dies, its running jobs are reset to queued after the configured stale threshold (default 15 minutes).

Sentinel protocol

A bundle is consumable only when both <sync_id>.json and <sync_id>.ready exist and the JSON has status = completed and verification.passed = true. The importer recomputes manifest_sha256 at consumption time so audit history records what we actually ingested.

Source-of-truth mapping

  • source/source.json -> asset_source (cold provenance).
  • source/data/photo.manifest.json + photo.analysis.json + photo.meaning.json + photo.family.json -> asset_ai_run rows with explicit analysis_kind; unknown filenames are captured with source_data:<file>.
  • Bundled cover_hash -> asset_cover linked to the parent asset.
  • Containers of type gallery -> asset_gallery + asset_gallery_item junctions.

Idempotency + integrity

Every multi-row write is wrapped in AdminDB::transaction. Hash-based UNIQUE keys make re-running the same batch a no-op. Per-item failures isolate to ingest_batch_item.decision = failed with last_error; the batch becomes partial when any siblings still succeeded.

Read-only mount + ledger boundary

The /mnt/s3-sync mount is read-only by configuration. The importer never writes to upstream or deletes .ready sentinels; all consumer state lives in ingest_batch / ingest_batch_item / ingest_event / import_job in admin_panel.

Walks the read-only mount for new and updated `.ready` manifests.
View import tasks

Import Queue 15 batches

Newest and unfinished batches first. Tick the checkboxes to bulk-queue. The background worker processes the queue in priority + FIFO order.

sync_idTypeActionStatusJobItemsBytesUpdated
6df12fb8-3d5b-42ca-bcec-3999624acc82assetupdatepreflight_passed-4172.8 MB2026-04-30 00:32:19Open
ea26e6fe-f86f-402c-be5b-de5c1f509143eventupdatepending-632.20 GB2026-04-30 00:29:20Open
30e9ba08-1310-4fca-87ca-0dad1311c910galleryimportpending-27228.3 MB2026-04-30 00:29:19Open
443ae22a-2ed3-4e21-95e4-b3d89d95a9b9collectionimportpending-55490.0 MB2026-04-30 00:29:19Open
72d5953b-8489-4eeb-acd3-166fdafa3c49collectionupdatepending-374.81 GB2026-04-30 00:29:19Open
a4125a5f-05cf-4587-bcaa-746885cfdc3bgalleryimportpending-251.50 GB2026-04-30 00:29:19Open
e870431d-f55c-4c8e-9133-1335a823cf65galleryupdatepending-33255.4 MB2026-04-30 00:29:19Open
82198374-b74d-445f-90f7-7cd4002f3856assetimportpending-2274.2 MB2026-04-30 00:29:18Open
a45298ec-f243-4035-825f-7bd847194dc8assetimportpending-2463.5 MB2026-04-30 00:29:18Open
de2d07be-eea7-4282-84aa-f57bca0b4e68galleryimportpending-47281.8 MB2026-04-30 00:29:18Open
a09117d8-8013-4a85-8c57-b2ccdb3d36f6eventupdateimported-202026-04-30 00:34:04Open
7506599b-9559-4d52-bc1c-24a74631e598assetimportimported-212.9 MB2026-04-30 00:34:02Open
e1586fc0-d5ed-479f-b38f-82abd2e6d88cassetupdateimported-27.6 MB2026-04-30 00:32:26Open
bc02ed61-9d39-4538-952a-ed4ced680e96assetupdateimported-4583.4 MB2026-04-30 00:32:25Open
37e428d2-a4f6-4a31-bacf-0c835fb24084galleryimportimported-1327.24 GB2026-04-30 00:31:02Open