fix(database): restore api_cache.cached_at read by the playback freshness gate
Main stopped compiling: the v21 column drop treated cached_at as never-read, but the fresh-cache-first playback metadata gate (ApiCacheSingleton.getIfFresh, from the playback start-latency fix) reads it on every Plex and Jellyfin playback start, and a later cleanup removed the put() stamp the gate depends on. Reinstate the column, keep the v21 migration to the connections half only (it never shipped in a release), restore the explicit put() timestamp - on conflict the upsert only updates the companion's columns, so without it a refreshed row would keep its original write time and read as permanently stale - and copy cached_at through the pinned-metadata rescope statement again. The v21 migration test now pins that api_cache is left untouched.
This commit is contained in:
@@ -141,7 +141,15 @@ abstract class ApiCache {
|
||||
Future<void> put(ServerId serverId, String endpoint, Map<String, dynamic> data) async {
|
||||
final key = _buildKey(serverId, endpoint);
|
||||
final encoded = await tryIsolateRun(() => jsonEncode(data));
|
||||
await _db.into(_db.apiCache).insertOnConflictUpdate(ApiCacheCompanion(cacheKey: Value(key), data: Value(encoded)));
|
||||
// The explicit stamp matters: on conflict the upsert only updates the
|
||||
// companion's columns, so relying on the column default would leave a
|
||||
// refreshed row carrying its original write time and [getIfFresh] would
|
||||
// treat just-refetched data as stale.
|
||||
await _db
|
||||
.into(_db.apiCache)
|
||||
.insertOnConflictUpdate(
|
||||
ApiCacheCompanion(cacheKey: Value(key), data: Value(encoded), cachedAt: Value(DateTime.now())),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> deleteForServer(ServerId serverId) async {
|
||||
|
||||
Reference in New Issue
Block a user