fix: preserve queued settings and recover interrupted or corrupt state

This commit is contained in:
Codex
2026-10-13 09:32:50 +08:00
parent 5ceab20b67
commit da5b8076a0
16 changed files with 373 additions and 50 deletions
+14
View File
@@ -46,4 +46,18 @@ class FileSnapshotStore extends SnapshotStore {
await temporary.rename(_file.path);
return previous;
}
@override
Future<AppSnapshot> startFresh() async {
await directory.create(recursive: true);
final stamp = DateTime.now().toUtc().microsecondsSinceEpoch;
for (final file in [_file, _backup]) {
if (await file.exists()) {
await file.rename('${file.path}.damaged-$stamp');
}
}
final fresh = AppSnapshot();
await save(fresh);
return fresh;
}
}