chore: Update SDK and remove boxes on corruption
This commit is contained in:
parent
1f9967b6bc
commit
335fe36130
2 changed files with 14 additions and 3 deletions
|
|
@ -12,6 +12,9 @@ import 'package:hive_flutter/hive_flutter.dart';
|
|||
import 'package:matrix/matrix.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import '../client_manager.dart';
|
||||
import '../famedlysdk_store.dart';
|
||||
|
||||
class FlutterFluffyBoxDatabase extends FluffyBoxDatabase {
|
||||
FlutterFluffyBoxDatabase(
|
||||
String name,
|
||||
|
|
@ -60,7 +63,15 @@ class FlutterFluffyBoxDatabase extends FluffyBoxDatabase {
|
|||
await _findDatabasePath(client),
|
||||
key: hiverCipher,
|
||||
);
|
||||
await db.open();
|
||||
try {
|
||||
await db.open();
|
||||
} catch (_) {
|
||||
Logs().w('Unable to open FluffyBox. Delete database and storage key...');
|
||||
await Store().deleteItem(ClientManager.clientNamespace);
|
||||
const FlutterSecureStorage().delete(key: _cipherStorageKey);
|
||||
await db.clear();
|
||||
rethrow;
|
||||
}
|
||||
Logs().d('FluffyBox is ready');
|
||||
return db;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue