fix: preserve queued settings and recover interrupted or corrupt state
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user