fix(app): restore playback and state lifecycle contracts

This commit is contained in:
edde746
2026-07-25 16:16:04 +02:00
parent 73f4a3e055
commit 4af77f4696
58 changed files with 2448 additions and 363 deletions
+10 -2
View File
@@ -83,8 +83,9 @@ class AppDatabase extends _$AppDatabase {
static final Object _durabilityZoneKey = Object();
static final SerialFutureQueue _tvosRecoveryQueue = SerialFutureQueue();
/// Resolves and opens the production database, then reconciles tvOS
/// recovery before returning it to startup consumers.
/// Resolves and opens the production database, eagerly completing Drift
/// setup and migrations on non-tvOS before returning. tvOS recovery retains
/// ownership of database access ordering.
static Future<AppDatabaseBootstrap> open({
bool isTvos = const bool.fromEnvironment('TVOS_BUILD'),
File? databaseFile,
@@ -110,6 +111,13 @@ class AppDatabase extends _$AppDatabase {
final store = recoveryStore ?? TvosDatabaseRecoveryStore(prefs, isTvos: isTvos);
final database = AppDatabase._((executorFactory ?? _createNativeDatabase)(file), recoveryStore: store);
try {
if (!isTvos) {
// Drift executors open lazily. Force the connection through setup and
// migrations while failures are still covered by this close/rethrow
// boundary and the caller's startup download-recovery decision.
await database.customSelect('SELECT 1').get();
// It deliberately does not claim capacity for a later write.
}
final outcome = await _tvosRecoveryQueue.run(
() => store.reconcile(
databaseExisted: databaseExisted,