refactor(offline-cache): re-wire Tauri onto qbz-offline-cache; delete old module

Completes Slice 0. src-tauri now depends on the qbz-offline-cache crate; the
old src-tauri/src/offline_cache/ implementation files are deleted. What remains
in that module is a thin shim: a re-export of the crate plus the Tauri glue.

- offline_cache/mod.rs: pub use qbz_offline_cache::* + tauri_cache_sink (maps
  CacheEvent -> the exact legacy offline:caching_*/offline:unlock_* app.emit
  shapes, so the Svelte frontend is unchanged) + core_client (resolves the core
  qbz_qobuz::QobuzClient from the CoreBridge for the download pipeline).
- Cache/redownload/migration commands: drop the legacy crate::api::QobuzClient
  (state.client) + the CoreBridge double-plumb; pass one core client + an
  app.emit-backed CacheEventSink. Unused `state: State<AppState>` params dropped.
- Playback + library cached-resolution call sites: pass &tauri_cache_sink(..)
  to load_cmaf_bundle_with_ui_events instead of &app_handle.
- session_lifecycle: apply_persisted_limit now reads the persisted value here;
  purge takes &library.db directly.
- migration: qobuz_client is the Option-wrapped core client (consistent with the
  downloader); None mid-loop is recorded as a per-track failure.

Full src-tauri cargo check passes; behaviour-preserving for the Svelte frontend.
Backend extraction (ADR-006) done — next is Slice 1 (shared tier-walk in core).

cc
This commit is contained in:
vicrodh committed 2026-05-27 20:09:09 -06:00
1 parent b17bbbd442
commit c8158bf419
19 files changed
+213 -3359

No files matched your search

+11 -2
View File
@@ -175,7 +175,7 @@ pub async fn migrate_legacy_cached_files(
track_ids: Vec<u64>,
tracks_dir: PathBuf,
offline_root: String,
qobuz_client: Arc<RwLock<QobuzClient>>,
qobuz_client: Arc<RwLock<Option<QobuzClient>>>,
library_db: Arc<Mutex<Option<LibraryDatabase>>>,
) -> MigrationStatus {
let total = track_ids.len();
@@ -197,12 +197,21 @@ pub async fn migrate_legacy_cached_files(
// Lock client for this migration
let client_guard = qobuz_client.read().await;
let Some(client) = client_guard.as_ref() else {
status.failed += 1;
status.errors.push(MigrationError {
track_id,
error_message: "QobuzClient not initialized".to_string(),
});
status.processed += 1;
continue;
};
match migrate_single_track(
track_id,
legacy_path.clone(),
&offline_root,
&*client_guard,
client,
library_db.clone(),
)
.await