Background jobs and scheduling
RomM runs long work outside the HTTP request path. An RQ worker reads jobs from Redis and performs scans, data updates, conversions, sync work, and cleanup. The task API and the web client expose the task catalog and job status so an operator can start allowed work and follow its progress.
Execution model
RQ worker execution
The RQ worker executes queued Python tasks. Redis provides the shared queues and the job state. Five queues separate long scans, streaming work, interactive work, routine work, and low-priority task jobs.
| Queue | Main use | Example |
|---|---|---|
scans | Long-running library scans | A scheduled or interactive library scan |
streaming | Streaming teardown and exit-save work | A streaming session cleanup |
high | High-priority interactive work | An urgent scan-related request |
default | General background work | Work that does not need scan or low-priority handling |
low | Scheduled and task-endpoint jobs | A manual task started through /tasks/run/{task_name} |
The scheduler is a separate process. At start, rq cron registers enabled scheduled tasks that have a cron rule. A changed enable flag or cron rule takes effect after the scheduler restarts.
References: entrypoint.sh• L50-85 backend/…/rq_worker.py• L7-25 backend/…/redis_handler.py• L29-66 backend/…/cron_config.py• L1-36
Task lifecycle
The task registry gives each task a stable name. The name is the shared address used by the API, cron, and queued job payload. A task also declares its type, display data, enable state, manual-run policy, schedule, timeout, result lifetime, and queue.
The normal lifecycle is:
- The cron process registers enabled periodic tasks.
- A cron event, API request, socket request, or file change enqueues a job by task name.
- The worker resolves the name through the registry and runs the task.
- The task writes progress data to job metadata when it supports progress.
- The API reads the job state and metadata for the operator interface.
Scheduled scans use a dispatch job so the actual scan enters the scan queue and can report worker failure to scan clients. Other scheduled jobs call the common name-based runner. The name-based payload keeps queued work independent of the Python location of a task.
Non-scan tasks notify the user who started them when they finish. A failure also notifies administrators. Scan tasks report their own completion because their clients need scan counts.
This diagram shows how task requests and scheduled events move through Redis to execution and status reporting.
flowchart LR
A[Scheduler or operator] --> B[Task registry]
C[Filesystem watcher] --> B
B --> D[Redis queue]
D --> E[RQ worker]
E --> F[Task name runner]
F --> G[Task work]
E --> H[Job state and metadata]
H --> I[Task status API]
I --> J[Web client]
Each job has a time limit. Scans use a longer limit than general tasks. Results remain available for the configured result lifetime so the operator can view a completed or failed job after the worker finishes.
References: backend/…/registry.py• L34-123 backend/…/tasks.py• L20-55 backend/…/tasks.py• L58-121 backend/…/cron_config.py• L14-35 backend/…/tasks.py• L228-292 backend/…/__init__.py• L204-218
Task entry points
Task catalog
The task API presents manual tasks, selected scheduled tasks, and a filesystem watcher entry. The catalog shows whether a task is enabled, whether an operator may run it, and its cron rule. All task routes require the task-run scope.
The operator-facing catalog covers these jobs:
| Group | Jobs | Purpose |
|---|---|---|
| Scheduled | Library rescan; LaunchBox and Switch TitleDB updates; recommendation build; image conversion; orphaned-resource cleanup; ZIP-cache cleanup; conversion-cache cleanup | Keep library data, provider data, recommendations, artwork, and stored resources current |
| Manual | Missing-ROM cleanup; missing-firmware cleanup; sync-folder scan; save-content-hash recompute; ROM sort-key recompute; library conversion | Repair, convert, or process data on demand |
| Watcher | Filesystem watcher | Show whether library changes can trigger a delayed rescan |
The registry also contains scheduled jobs that run only from their cron rules. These include netplay cleanup, temporary-upload cleanup, streaming-session reaping, sync-session cleanup, snapshot pruning, audit-log cleanup, RetroAchievements progress sync, and push-pull sync. The catalog does not expose every scheduled job as an operator action.
References: backend/…/registry.py• L54-60 backend/…/registry.py• L116-132 backend/…/registry.py• L193-230 backend/…/registry.py• L243-313 backend/…/tasks.py• L48-63 backend/…/tasks.py• L190-225 backend/…/cleanup_sync_sessions.py• L12-30 backend/…/reap_streaming_sessions.py• L42-67
Manual task requests
The POST /tasks/run/{task_name} endpoint looks up the requested name in the manual and visible scheduled task catalog. It creates a low-priority job and returns its job ID and initial state. An optional JSON object supplies task arguments.
An operator can run a task only when its manual-run policy allows it. Most tasks require both the manual-run setting and the enabled setting. Some provider update tasks allow a manual rebuild when their scheduled flag is off but the provider is available. The endpoint also checks for a live low-priority worker before it queues the job. This avoids accepting work that would remain queued without a worker.
The argument object is nested inside the request body. This keeps request data from changing which task the endpoint authorized. Manual runs are also recorded as task-run audit events.
Library conversion is an enabled manual action only when the ROM conversion service is enabled. It is marked destructive because it replaces source files with the selected platform format. The task runs as a single instance so two library-wide replacements do not compete for the same files.
ROM sort-key recompute is a manual update for changes to the configured article list used in sorting. It re-derives automatic keys in batches while preserving custom keys. The task records the new article list only after the full pass succeeds, so an interrupted pass can be repeated.
References: backend/…/tasks.py• L295-359 backend/…/registry.py• L63-104 backend/…/registry.py• L243-267 backend/…/recompute_name_sort_keys.py• L13-52 backend/…/tasks.py• L183-198 backend/…/update_launchbox_metadata.py• L116-121 backend/…/update_switch_titledb.py• L44-48
Startup jobs
Startup registers enabled recurring jobs and can enqueue one-time repair work when current data needs it. Stable job IDs prevent a restart from creating duplicate repair work.
Startup can enqueue a save-hash recompute when save rows need the current hash and a WebP backfill when WebP conversion is enabled. These jobs do not block application startup.
References: backend/startup.py• L53-101 backend/startup.py• L104-169 backend/…/recompute_save_content_hashes.py• L53-69
Scan jobs
Library scans
A library scan compares the configured library with the database and enriches the result with enabled metadata sources. It also fills platform records with available provider discovery data. The scheduled scan covers the whole library with a quick scan. It selects metadata sources at run time so disabled providers are not used.
The scheduled task checks its feature flag when it runs. If the flag is off or no metadata source is enabled, it returns empty scan statistics without scanning. Interactive scans can target platforms, ROMs, or filesystem slugs and use the high-priority scan queue.
The scan records counts for platforms, ROMs, firmware, and newly identified items. It writes these counts to RQ metadata while it runs so status clients can show progress before the job ends. Scan requests check scheduled, queued, and worker-held jobs to avoid overlapping work for the same scope.
References: backend/…/scan_library.py• L8-32 backend/…/scan_handler.py• L146-236 backend/…/registry.py• L54-63 backend/…/scan.py• L93-179 backend/…/scan.py• L1343-1379
Filesystem rescan jobs
The filesystem watcher turns valid library changes into delayed scan jobs. It ignores excluded paths and waits for the configured delay so a burst of changes can settle. A platform-directory change requests a full rescan. A change inside one platform requests a quick scan for that platform.
The watcher checks for an existing full or platform scan before scheduling another one. This prevents repeated file events from filling the queue with duplicate work. The manual sync-folder scan is a separate, on-demand fallback for incoming files when filesystem events are missed. It runs only when the task is enabled, checks file-transfer devices with sync enabled, and sends each device's incoming files through the sync watcher in a worker thread. It reports whether the task was disabled, found no devices, or completed, with the number of processed files.
References: backend/watcher.py• L73-114 backend/watcher.py• L117-261 backend/…/sync_folder_scan.py• L18-63
Conversion and update jobs
Image conversion jobs
The image conversion job creates WebP copies for existing cover images. It is scheduled and can run manually when enabled. It validates each candidate, uses the shared image quality policy for static and animated images, skips images that already have a WebP copy, and reports processed files, errors, and total candidates.
When WebP conversion is enabled, startup also queues a one-time backfill. This reduces the gap between enabling WebP use and the next scheduled conversion.
References: backend/…/convert_images_to_webp.py• L11-18 backend/…/convert_images_to_webp.py• L60-99 backend/…/convert_images_to_webp.py• L135-236 backend/startup.py• L104-133
Library conversion jobs
The library conversion job changes matched ROM files to the format configured for each platform. It publishes each converted file beside its source, updates the ROM name or playlist references, moves file-linked saves and snapshots to the replacement files, then removes the source files and refreshes the ROM's file view.
The job skips files that already use the target format and records unsupported, unmatched, and failed work separately from successful conversions. It rejects an output name that already exists and refuses a CUE conversion when another CUE file shares its tracks. It also updates playlists when a multi-file ROM changes names. The conversion keeps originals until the ROM and its related records point to the new files, and restores the prior references when that update fails. The conversion service must be enabled, and the task reports processed ROMs, errors, converted items, and saved bytes through the conversion progress view.
References: backend/…/convert_library.py• L225-272 backend/…/convert_library.py• L285-410 backend/…/registry.py• L268-282
Metadata update jobs
Metadata update jobs refresh local lookup stores from remote data. The Switch TitleDB job imports a JSON index. The LaunchBox job imports a large archive. Both write data in batches and report processed and total work.
LaunchBox keeps the previous store available during a refresh. On a first import, it marks the store as incomplete until all source data is written. The store becomes ready only after the import finishes. LaunchBox can run manually when its scheduled update or provider is enabled. Switch TitleDB remains manually available when its schedule is off.
References: backend/…/update_switch_titledb.py• L32-93 backend/…/update_launchbox_metadata.py• L103-143 backend/…/update_launchbox_metadata.py• L145-180 backend/…/update_launchbox_metadata.py• L318-328 backend/…/__init__.py• L6-24
Recommendation update jobs
The recommendation job rebuilds the similar-games index from library metadata, play history, and collections. It reports indexed ROMs as update progress and clears cached rankings after the new index is ready so later reads use the new graph.
References: backend/…/build_recommendations.py• L19-59
Device save sync jobs
The push-pull sync job keeps slot-bound save files aligned between RomM and configured devices over SSH/SFTP. It limits matching to saves visible to the device owner and with a non-null slot, so archival or web-only uploads do not enter device sync. It compares remote and server state with the last sync record and chooses a pull, push, no-op, or conflict result. It also pushes server saves that are missing on a device unless the sync record marks them as intentionally untracked.
Each device gets a sync session with planned, completed, and failed operation counts. Socket events expose start, progress, conflict, error, and completion state to the device owner. The job skips when the feature is disabled unless a caller explicitly forces the run. A separate manual sync-folder scan handles incoming files for sync-enabled file-transfer devices when watcher events are missed.
References: backend/…/sync_push_pull_task.py• L35-66 backend/…/sync_push_pull_task.py• L69-129 backend/…/sync_push_pull_task.py• L131-236 backend/…/sync_push_pull_task.py• L239-392 backend/…/sync_push_pull_task.py• L395-476 backend/…/sync_folder_scan.py• L30-63
Progress update jobs
The scheduled RetroAchievements job refreshes progress for users with a RetroAchievements account. For each user, it stores the latest provider progress and then maps the provider's award level to the status of every matching regional ROM. This keeps changes in game completion visible in the library without a manual action, while preserving the fetched progress if a status write fails.
The same per-user sync is available as a short RQ job after play activity. It emits an ra:synced event to the user's connected tabs with a success result. A failed short job is caught so its fixed job ID does not block the user's next refresh, while the scheduled task continues with the other users.
The job skips when the provider is disabled. It processes each eligible user independently, so one failed refresh does not stop the remaining users. Award levels map to incomplete, finished, or fully completed library states. An unrecognized award leaves the current status unchanged. One provider game ID can update all matching regional ROM rows. A stale provider response is not stored, and a failure while updating ROM status does not discard progress that was already stored. The scheduled task reports processed and total users through task progress.
References: backend/…/sync_retroachievements_progress.py• L18-80 backend/…/sync_retroachievements_progress.py• L82-131 backend/…/sync_retroachievements_progress.py• L134-171
Cleanup jobs
Resource cleanup jobs
Cleanup jobs remove data that has no valid owner or useful lifetime. They protect the database and filesystem from stale rows, orphaned resources, temporary upload data, expired cached archives, converted download caches, and old service records.
| Job | Schedule or trigger | Cleanup target |
|---|---|---|
| Orphaned resources | Configured schedule; manual run allowed | Platform and ROM resource directories with no matching database object |
| Missing ROMs | Manual; can be limited to selected platforms | Missing ROM rows, their resource directories, and smart collection membership |
| Missing firmware | Manual; can be limited to selected platforms | Missing firmware rows whose files are already absent |
| ZIP cache | Daily | Cached ZIP files past their tiered lifetime |
| Conversion cache | Daily at 04:00 | Converted download files past their lifetime or beyond the configured cache size |
| Temporary uploads | Hourly | Old chunked-upload directories |
| Netplay rooms | Every 30 minutes | Empty netplay rooms |
| Streaming sessions | Every minute | Sessions whose player stopped sending heartbeats |
| Sync sessions | Hourly | Sessions left open for more than 24 hours |
| Snapshot branches | Configured schedule | Expired save-sync branches and unreachable archival snapshots |
| Audit log | Daily at 04:30 when retention is positive | Audit events older than the configured retention period |
Orphaned-resource cleanup stops before destructive work when the database reports no platforms but resource directories remain. An operator must explicitly force that run. Missing-ROM cleanup deletes the stale row and its resource directory, then refreshes smart collections for the ROMs deleted in that run. A row deletion error is counted and does not stop other ROMs. Missing-firmware cleanup deletes only the stale row because the file is already absent.
The conversion-cache cleanup removes old converted download copies and can evict older copies when the cache reaches its configured size. It does not remove a copy while a download or conversion holds its cache entry. The task is scheduled directly and is not controlled by a separate enable flag.
Snapshot pruning removes save-sync branches older than the configured lifetime. It then removes archival snapshots that no longer have a ROM and have no content hash that can locate it. Before it deletes released snapshot files, it records the lost slot versions so later sync negotiation does not offer those versions again.
The streaming-session reaper skips its work during the restart grace period and handles sessions concurrently. The sync-session cleanup marks old open sessions as failed so a killed or disconnected client does not leave them open forever. Audit-log cleanup deletes in batches and does not register when retention is zero or negative.
References: backend/…/cleanup_orphaned_resources.py• L76-141 backend/…/cleanup_missing_roms.py• L32-91 backend/…/cleanup_missing_firmware.py• L31-83 backend/…/cleanup_zip_cache.py• L6-25 backend/…/cleanup_conversion_cache.py• L7-18 backend/…/conversion_cache.py• L382-449 backend/…/cleanup_upload_tmp.py• L9-43 backend/…/cleanup_netplay.py• L6-28 backend/…/reap_streaming_sessions.py• L42-67 backend/…/cleanup_sync_sessions.py• L12-30 backend/…/prune_snapshots.py• L7-23 backend/…/retention.py• L41-70 backend/…/cleanup_audit_log.py• L13-39
Data repair jobs
The save-hash recompute task repairs existing save rows after a hash rule change. It checks each save against the current file content, updates changed values, and reports missing files and errors. It is safe to repeat and uses bounded batches so a large save library does not remain in one worker result set.
The ROM sort-key recompute task repairs automatic ordering after the configured article list changes. It scans ROMs in bounded pages, replaces only derived keys, and leaves user-defined keys unchanged. A shared marker records which article list produced the stored keys after a successful full pass.
References: backend/…/recompute_save_content_hashes.py• L29-50 backend/…/recompute_save_content_hashes.py• L53-138 backend/…/recompute_name_sort_keys.py• L13-52 backend/startup.py• L57-101
Task status reporting
Status collection
The GET /tasks/status endpoint builds one current view from worker-held jobs, queued jobs, and finished or failed jobs on all queues. It sorts the result by the latest start, enqueue, or creation time. A job that no longer exists is removed from its registry instead of being returned as a broken status record.
The GET /tasks/{task_id} endpoint returns one job by ID. The status routes and the task catalog use the task-run scope, so task visibility and control share one access boundary.
References: backend/…/tasks.py• L228-292 backend/…/redis_handler.py• L62-76
Status metadata
Every task status has a task name, job ID, RQ state, and creation, enqueue, start, and end times. The task type selects the progress shape in the response.
| Task type | Progress view |
|---|---|
| Scan | Scan counts |
| Conversion | Processed, error, and total counts |
| Update | Processed and total counts |
| Cleanup | Cleanup counters when the task publishes cleanup statistics |
| Sync | Session and socket progress for device sync |
| Watcher and generic | Common job state without task-specific counters |
The status builder fills missing scan counters with zero for older jobs. It also converts older single-platform cleanup metadata to the current platform-list shape. This keeps retained Redis metadata compatible with the current response contract. Metadata updates are ignored when a task runs outside an RQ job context so they do not stop the task.
The web client maps RQ states such as queued, started, finished, failed, canceled, and deferred to display labels and visual state. Push-pull sync uses sync sessions and socket events for detailed progress instead of RQ progress metadata.
References: backend/…/tasks.py• L79-187 backend/…/__init__.py• L91-147 backend/…/tasks.py• L124-133 backend/…/sync_push_pull_task.py• L80-204 frontend/…/tasks.ts• L1-81
Frontend task view
The web client uses the task API to load the catalog, start an allowed task, fetch one job, and refresh the full status list. Its task store keeps watcher, scheduled, manual, and status data separate so the settings view can show available actions and active work.
The status response is a typed union by task type. This lets the client render task-specific progress without changing the common job lifecycle fields.
References: frontend/…/task.ts• L5-19 frontend/…/tasks.ts• L6-49 frontend/…/tasks.ts• L1-21
Change checklist
When these files or sections are changed, remember to consider these:
- Keep each task name aligned across backend/…/registry.py, cron registration, manual task lookup, and the function name stored in queued jobs.
- When adding a task type or progress payload, update the backend response union and the frontend status union and display maps together.
- When changing a queue or scan entry point, update scan overlap checks so queued, scheduled, and worker-held jobs remain visible to deduplication.
- When changing a schedule enable flag or cron value, restart the cron process and check the task's run-time disabled behavior.
- When changing job metadata keys, update the task writer, status response builder, generated API types, and frontend progress reader as one contract.
- When changing result retention or timeouts, check both cron registration or enqueue options and the backend task configuration.
- When changing a cleanup task's scope argument, update every caller to use the same
platform_idscontract so a limited cleanup cannot become unscoped. - When changing missing-ROM cleanup, preserve deletion of the stale row and resource directory, per-ROM error isolation, and the smart-collection refresh after successful deletions.
- When changing scheduled scan dispatch, preserve its scan-queue placement and failure callback so a worker failure reaches scan clients.
- When changing cleanup progress fields, keep compatibility for retained jobs written by the prior field shape.
- When changing audit-log retention, keep the enabled condition and cutoff calculation aligned so a non-positive value does not register a destructive job.
- When changing snapshot retention or branch cleanup, keep branch expiry, unreachable archival cleanup, slot-loss recording, and snapshot file removal in the same task flow.
- When changing LaunchBox import or cache readiness, keep the previous-store behavior, first-import marker, schema stamp, and final marker cleanup aligned.
- When changing image discovery or conversion, keep validation, existing-WebP skipping, shared image quality, and conversion progress counts aligned with the task status contract.
- When changing library conversion targets or file replacement, keep ROM names, playlist entries, filesystem files, refreshed ROM-file records, and file-linked save or snapshot references aligned.
- When changing conversion-cache expiry or size handling, preserve the lock checks that protect active downloads and conversions.
- When changing RetroAchievements progress mapping, keep provider checks, eligible-user progress counts, award-to-library mapping, regional ROM matching, stale-response handling, and per-user error isolation aligned.
- When changing after-play RetroAchievements enqueueing, preserve one active job per user, the
ra:syncedevent contract, and the rule that a failed job does not block the user's next refresh. - When changing push-pull sync, keep owner visibility filtering, slot-bound save filtering, intentional-delete tracking, sync-session counts, and socket event states aligned.
- When changing the sync-folder fallback, keep the enabled check, file-transfer device filter, incoming-file tuple shape, and processed-file count aligned with the sync watcher.
- When adding a cleanup task for a live service, keep its restart grace period, stale threshold, and resource-specific failure handling aligned with the service lifecycle.
- When changing the configured sort articles, keep the recompute task's derived-key rule, custom-key preservation, and successful-pass marker aligned.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The worker cannot reach Redis | Queued and scheduled work does not execute, and status cannot show the complete job set | Keep Redis available to the API, scheduler, and worker through the same configured connection |
| A manual task request has no live low-priority worker | The API rejects the request instead of leaving the job queued without a worker | Keep a low-priority worker listening before using the manual task endpoint |
| A schedule flag or cron rule changes while cron is running | The old cron registration remains | Restart the cron process after schedule changes |
| A scheduled library scan runs with its feature disabled or no metadata source | The job returns empty scan statistics and does not scan | Enable the scheduled scan and at least one metadata provider |
| A filesystem burst creates repeated change events | Duplicate scan jobs consume worker capacity | The watcher checks full, platform, queued, scheduled, and running scan jobs before enqueueing |
| The database reports no platforms while resources remain on disk | Cleanup could remove a valid library during an outage or migration | Orphaned-resource cleanup skips the destructive pass unless force is used |
| A queued job names a task no longer in the registry | The worker fails the job with a task-not-found error | Keep stable task names while queued jobs may still exist |
| A long scan or metadata import exceeds its timeout | RQ marks the job failed before it completes | Use the scan timeout and the extended LaunchBox timeout for their long work |
| A cleanup caller sends a single-platform argument to a multi-platform task | The intended limit can be ignored | Pass platform_ids to missing-ROM and missing-firmware cleanup |
| A missing-ROM database deletion fails | That ROM remains and later items can still be processed | Keep per-ROM error handling and report the error count |
| Smart collection refresh fails after missing-ROM deletion | The deleted ROMs are gone, but smart collections may still show stale membership until a later refresh | Keep the post-delete refresh and its isolated error logging |
| A library conversion runs while the ROM conversion service is disabled | The task completes without converting files | Enable the ROM conversion service before starting library conversion |
| A conversion target already exists or shares tracks with another CUE file | The affected ROM conversion fails while other ROMs can continue | Keep target names unique and do not share source tracks between CUE files |
| A conversion cannot update the ROM name, playlist, file records, or file-linked state references | The source files remain in place and the affected conversion is reported as failed | Keep database names, playlist entries, published outputs, and related record moves within the conversion task's update sequence |
| A first LaunchBox import stops before all source data is written | The cache can contain only part of the provider data | Keep the initial-import marker until the store is stamped ready |
| Audit retention is zero or negative | Old audit events remain because cleanup is not registered | Use a positive retention period when automatic cleanup is required |
| A converted download cache is used while cleanup inspects it | A live converted file could be deleted during a download or conversion | Keep the cache-entry lock around serving, conversion, and cleanup |
| Snapshot pruning is disabled or its schedule does not run | Expired sync branches and unreachable archival snapshots remain, with their content files | Keep snapshot pruning enabled and its cron rule registered |
| A push-pull device has no SSH host or save directories | The sync ends with an error or no-directory result | Provide valid SSH settings and at least one save directory |
| A save is not slot-bound, is outside the device owner's visibility, or is marked intentionally untracked | The sync skips it instead of pairing or recreating it on the device | Keep archival saves out of sync, enforce owner visibility, and preserve device tracking state |
| A sync or streaming client stops without closing its session | The session can remain open or hold resources | Run stale sync-session cleanup and streaming-session reaping on their schedules |
| A manual sync-folder scan is disabled or no file-transfer device is sync-enabled | Incoming files remain unprocessed and the task returns without scanning | Enable the task and keep the target device in file-transfer mode with sync enabled |
| RetroAchievements is disabled | The scheduled and after-play jobs skip progress updates | Enable the provider before relying on automatic progress updates |
| A user's progress fetch fails | That user's stored progression and ROM status are not refreshed, but later users still process | Keep the per-user error boundary and retry the provider refresh later |
| A provider response is stale when it is stored | The stale progression is dropped and its ROM statuses are not updated | Keep the freshness check in the user progression write and retry the refresh |
| A ROM status write fails after a user's progress fetch succeeds | Provider progression is stored, but matching ROM statuses are not updated for that user | Keep status updates inside a separate per-user error boundary |
| A short after-play sync fails without releasing its fixed job ID | The user's next progress refresh can be rejected as a duplicate | Catch the job failure and release or replace the fixed ID before the next enqueue |
| The configured sort articles change without a sort-key recompute | Automatic ROM ordering stays based on the prior article list | Run the ROM sort-key recompute task after changing the setting |
| A sort-key recompute stops before its final marker is written | The next run repeats the scan instead of treating partial work as complete | Clear the applied-articles marker before the pass and write it only after all batches succeed |
Key files
| File | Why to read it |
|---|---|
| backend/…/tasks.py | Defines the task contract, task types, name-based execution, notifications, failure handling, and job metadata updates. |
| backend/…/registry.py | Defines stable task names, scheduled and manual catalogs, queue enqueue behavior, and scheduled scan dispatch. |
| backend/…/cron_config.py | Shows how enabled periodic tasks become cron entries and how scheduled scans are dispatched. |
| backend/…/redis_handler.py | Defines the Redis connection and the RQ queues. |
| entrypoint.sh | Shows how the scheduler, worker, and filesystem watcher start. |
| backend/startup.py | Shows startup scheduling and one-time repair-job enqueueing. |
| backend/…/tasks.py | Defines the task catalog, manual-run endpoint, worker check, and status endpoints. |
| backend/…/scan.py | Shows scan enqueueing, overlap detection, and scan progress data. |
| backend/…/scan_handler.py | Shows platform discovery, ROM scan orchestration, and scan-time resource handling. |
| backend/watcher.py | Shows how filesystem changes become delayed quick or full scans. |
| backend/…/scan_library.py | Shows the recurring whole-library scan, its run-time checks, and source selection. |
| backend/…/sync_folder_scan.py | Shows the on-demand fallback that finds incoming files for sync-enabled file-transfer devices and sends them to the sync watcher. |
| backend/…/convert_images_to_webp.py | Shows artwork conversion, candidate validation, image quality handling, and conversion progress. |
| backend/…/convert_library.py | Shows platform-format library conversion, staged file replacement, playlist updates, related save and snapshot moves, and conversion progress. |
| backend/…/cleanup_missing_roms.py | Shows scoped removal of missing ROMs, resource cleanup, deletion error isolation, and smart-collection refresh. |
| backend/…/recompute_name_sort_keys.py | Shows repair of automatic ROM sort keys after sorting article changes. |
| backend/…/cleanup_conversion_cache.py | Shows the daily task that removes stale converted download caches. |
| backend/…/conversion_cache.py | Shows conversion-cache lifetime, size eviction, and protection for active cache entries. |
| backend/…/cleanup_orphaned_resources.py | Shows destructive cleanup and its empty-database safety guard. |
| backend/…/prune_snapshots.py | Shows the scheduled task that removes expired sync branches and unreachable archival snapshots. |
| backend/…/retention.py | Shows snapshot retention, slot-loss recording, and removal of released snapshot content. |
| backend/…/cleanup_sync_sessions.py | Shows how abandoned device sync sessions become failed. |
| backend/…/reap_streaming_sessions.py | Shows scheduled cleanup for abandoned streaming sessions. |
| backend/…/cleanup_audit_log.py | Shows retention-based audit cleanup and batch behavior. |
| backend/…/cleanup_missing_firmware.py | Shows removal of stale firmware rows and scoped cleanup progress. |
| backend/…/recompute_save_content_hashes.py | Shows restart-safe save-hash repair and progress reporting. |
| backend/…/update_launchbox_metadata.py | Shows provider-aware LaunchBox refresh, cache readiness, and update progress. |
| backend/…/update_switch_titledb.py | Shows Switch TitleDB refresh and update progress. |
| backend/…/sync_push_pull_task.py | Shows device save sync, owner-visible slot filtering, conflict handling, missing-save pushes, session progress, and socket events. |
| backend/…/sync_retroachievements_progress.py | Shows scheduled and after-play provider progress refresh, freshness handling, per-user isolation, award mapping, regional ROM matching, user events, and per-user ROM status changes. |
| frontend/…/task.ts | Shows client calls for task discovery, execution, and status. |
| frontend/…/tasks.ts | Shows how the client stores task groups and status snapshots. |
Related pages: Backend runtime and operations, Backend runtime composition, Notifications and audit, Library scanning and filesystem, Metadata enrichment