fix: Clearing corrupted boxes
If a box is corrupted the clear function fails on it. Then we should delete the box from the disk. Currently we use the Hive.deletefromDisk() method which does not work because it deletes only open boxes, but the box is obviously not open in this case.
This commit is contained in:
parent
00cc439122
commit
dec32975e2
|
|
@ -249,8 +249,13 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
|
||||||
Future<void> clear(int clientId) async {
|
Future<void> clear(int clientId) async {
|
||||||
Logs().i('Clear and close hive database...');
|
Logs().i('Clear and close hive database...');
|
||||||
await _actionOnAllBoxes((box) async {
|
await _actionOnAllBoxes((box) async {
|
||||||
|
try {
|
||||||
await box.deleteAll(box.keys);
|
await box.deleteAll(box.keys);
|
||||||
await box.close();
|
await box.close();
|
||||||
|
} catch (e) {
|
||||||
|
Logs().v('Unable to clear box ${box.name}', e);
|
||||||
|
await box.deleteFromDisk();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue