another bandaid fix for hive box isn't open

This commit is contained in:
julian 2023-07-26 14:50:38 -06:00
parent 13e08acf06
commit 36747ca479

View file

@ -274,8 +274,15 @@ class DB {
{required dynamic key, required String boxName}) async =>
await mutex.protect(() async => await Hive.box<T>(boxName).delete(key));
Future<void> deleteAll<T>({required String boxName}) async =>
await mutex.protect(() async => await Hive.box<T>(boxName).clear());
Future<void> deleteAll<T>({required String boxName}) async {
await mutex.protect(() async {
Box<T> box = Hive.box<T>(boxName);
if (!box.isOpen) {
box = await Hive.openBox(boxName);
}
await box.clear();
});
}
Future<void> deleteBoxFromDisk({required String boxName}) async =>
await mutex.protect(() async => await Hive.deleteBoxFromDisk(boxName));