change: Delete hive database if corrupted

This commit is contained in:
Christian Pauly 2021-08-02 18:38:53 +02:00
parent 1f57ee110f
commit caae0ccd01
1 changed files with 7 additions and 1 deletions

View File

@ -87,7 +87,13 @@ class FlutterMatrixHiveStore extends FamedlySdkHiveDatabase {
encryptionCipher: hiverCipher,
);
Logs().i('Open Hive database...');
await db.open();
try {
await db.open();
} catch (e, s) {
Logs().e('Unable to open Hive. Delete and try again...', e, s);
await Hive.deleteFromDisk();
await db.open();
}
Logs().i('Hive database is ready!');
return db;
}