db migrate to force firo cache clear

This commit is contained in:
julian 2022-12-14 10:26:48 -06:00
parent cf82374a0c
commit c84ae8ff21
2 changed files with 16 additions and 1 deletions

View file

@ -38,7 +38,7 @@ abstract class Constants {
// Enable Logger.print statements
static const bool disableLogger = false;
static const int currentHiveDbVersion = 3;
static const int currentHiveDbVersion = 4;
static int satsPerCoin(Coin coin) {
switch (coin) {

View file

@ -141,6 +141,7 @@ class DbVersionMigrator {
// try to continue migrating
return await migrate(2, secureStore: secureStore);
case 2:
await Hive.openBox<dynamic>(DB.boxNamePrefs);
final prefs = Prefs.instance;
@ -154,6 +155,20 @@ class DbVersionMigrator {
boxName: DB.boxNameDBInfo, key: "hive_data_version", value: 3);
return await migrate(3, secureStore: secureStore);
case 3:
// clear possible broken firo cache
await DB.instance.deleteBoxFromDisk(
boxName: DB.instance.boxNameSetCache(coin: Coin.firo));
await DB.instance.deleteBoxFromDisk(
boxName: DB.instance.boxNameUsedSerialsCache(coin: Coin.firo));
// update version
await DB.instance.put<dynamic>(
boxName: DB.boxNameDBInfo, key: "hive_data_version", value: 4);
// try to continue migrating
return await migrate(4, secureStore: secureStore);
default:
// finally return
return;