Expand description
Tauri commands for the offline “browse & queue” feature.
TRACES: UR-002, UR-007, UR-024 | JA-004, JA-016 | DR-012, DR-027
Two backend pieces support browsing the full server catalog while offline and queueing downloads that fire on reconnect:
sync_full_catalogwalks every library while online and persists all items to the offline cache so the whole catalog is browsable (greyed out) offline. It reuses [HybridRepository::cache_items_from_server], which in turn reusesOfflineRepository::save_to_cache(setssynced_at, which is whatget_itemsbranch 3 serves offline).resume_queued_downloadsresolves and pumps thependingdownload rows that were queued offline (they havestream_url IS NULL), mirroring the heal-and-pump pattern inplayer_preload_upcoming.
Structs§
- Catalog
Index Event - Progress of a background index pass, for the staleness hint in the UI.
- Catalog
Sync Result - Catalog
Sync Status - Index
Pass 🔒Guard - Clears
INDEX_IN_PROGRESShowever the pass leaves — including on the?early return whenget_librariesfails, which a plain store at the end of the function would leak. - Resume
Queued Result
Constants§
- CATALOG_
INDEX_ EVENT - Kebab-case, per the project’s event convention.
- CATALOG_
INDEX_ 🔒FIRST_ CHECK - Delay before the first staleness check, to let sign-in complete and the repository be registered. Without it the first check runs against an empty repository manager and a fresh install would sit unindexed until the next tick.
- CATALOG_
INDEX_ 🔒TICK - How often the scheduler wakes to check staleness. Far shorter than the TTL
because a tick is nearly free — one indexed
app_settingslookup — and it is what makes the indexer responsive to events it cannot subscribe to: signing in, and coming back online. The TTL, not the tick, decides whether a crawl actually happens. - CATALOG_
INDEX_ 🔒TTL - How long an index stays fresh before a re-index is due.
- CATALOG_
ITEM_ 🔒TYPES - Item types worth caching for offline browsing: containers the library
landing pages render plus the playable leaves users queue for download.
MusicArtistandPlaylistare here because search groups results by them (UR-060’s Artists group). Without them in the crawl, the local index can never answer an artist query and those groups can only ever be filled by the server leg. Keep this in step with whatprune_stale_catalogis allowed to sweep — the crawl is only authoritative for the types it asks for. - LAST_
CATALOG_ 🔒SYNC_ KEY - app_settings key holding the RFC-3339 timestamp of the last successful full-catalog sync.
- VIDEO_
ITEM_ 🔒TYPES - Jellyfin item types whose download is a video stream rather than an audio
one. The download queue stores an opaque
media_type(‘audio’/‘video’); this is where the taxonomy that produces it lives, so the frontend never has to know which item types are video.
Statics§
- INDEX_
IN_ 🔒PROGRESS - Guards against two passes running at once. Replaces the frontend’s
syncInProgressboolean inofflineCatalog.ts, which could not see a pass started by the scheduler.
Functions§
- catalog_
sync_ status - Report the last-synced timestamp so the UI can show a hint / decide whether to trigger a fresh sync.
- index_
is_ 🔒due - Whether an index pass is due, given when one last completed.
- maybe_
run_ 🔒scheduled_ pass - One scheduler tick: check the preconditions, then index if due.
- read_
last_ 🔒sync - Read the last-sync timestamp straight from
app_settings. - requeue_
mistyped_ 🔒video_ downloads - Requeue video downloads that were fetched as audio.
- resolve_
pending_ 🔒download_ urls - Core of
resume_queued_downloads, factored out for testing: select everypending/stream_url IS NULLrow, resolve each viaresolve(returningNoneleaves the row pending), and heal the row so the pump can start it. Theresolveclosure receives(item_id, media_type, quality_preset). - resume_
queued_ downloads - Resolve the stream URL for every download row that was queued while offline
(
status = 'pending' AND stream_url IS NULL), then pump the queue so they start. Call this on reconnect. - run_
index_ 🔒pass - One full-catalog indexing pass, shared by the
sync_full_catalogcommand and the background scheduler (DR-109) so there is exactly one implementation and one concurrency guard. - set_
show_ server_ catalog - Control whether offline library queries reveal the full synced catalog (greyed-out, non-downloaded media) or only downloaded/local media.
- spawn_
catalog_ indexer - Start the background catalog indexer.
- sync_
full_ catalog - Walk every library on the server and persist all items to the offline cache so the full catalog is browsable offline (greyed out when not downloaded).