fix(offline-cache): touch last_accessed_at when a cached track plays

OfflineCacheDb::touch had no caller, so LRU eviction ordered by the
download date and evicted the most-played tracks first. Touch in
resolve_offline_bytes, the one resolver every offline play goes through.

cc
This commit is contained in:
vicrodh committed 2026-08-28 19:54:47 -06:00
1 parent e0a9f60336
commit ae9306988e
1 file changed
+11 -1
+11 -1
View File
@@ -33,7 +33,17 @@ pub async fn resolve_offline_bytes(
) -> Option<Vec<u8>> {
let row = {
let guard = offline.db.lock().await;
guard.as_ref()?.get_cmaf_bundle(track_id).ok().flatten()?
let db = guard.as_ref()?;
let row = db.get_cmaf_bundle(track_id).ok().flatten()?;
// A play IS an access. LRU eviction (`maintenance::check_cache_limit`)
// orders by `last_accessed_at`, which until now only the download
// wrote — so the cache evicted the tracks the user played most,
// oldest download first. This is the one place every offline play
// funnels through (both frontends and qbzd resolve here).
if let Err(e) = db.touch(track_id) {
log::debug!("[OfflineResolve] touch({track_id}) failed: {e}");
}
row
};
match row.cache_format {