Skip to content

Commit dc90d5e

Browse files
committed
fix(storage): route Hive-era installs to the fss9 fallback
1 parent bbc3de8 commit dc90d5e

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

lib/core/storage/storage_locator.dart

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,26 +79,37 @@ class StorageLocator {
7979
'StorageLocator: fss10 readAll returned ${data.length} entries',
8080
);
8181

82-
// Belt-and-suspenders: if FSS10 returns empty but the SQLite DB
83-
// from a prior install exists, treat it as a silent failure and
84-
// route to FSS9.
82+
// Belt-and-suspenders: if FSS10 returns empty but data from a prior
83+
// install exists, treat it as a silent failure and route to FSS9.
8584
if (data.isEmpty) {
8685
final docsDir = await getApplicationDocumentsDirectory();
8786
final dbFile = File(
8887
p.join(docsDir.path, 'bullbitcoin_sqlite.sqlite'),
8988
);
90-
if (await dbFile.exists()) {
89+
// A pre-v5 ("BULL" 0.x) install has no SQLite database — it kept
90+
// everything in Hive. Probing only for the database made such a
91+
// device look like a fresh install: it committed to fss10 and its
92+
// fss9/ESP secrets (seed material included) stayed invisible on
93+
// every later launch, flag included. Measured on a real
94+
// 0.4.3 → 6.13 upgrade.
95+
final hasLegacyHiveBoxes = await docsDir.list().any(
96+
(entity) => entity.path.endsWith('.hive'),
97+
);
98+
if (await dbFile.exists() || hasLegacyHiveBoxes) {
9199
log.warning(
92-
'StorageLocator: fss10 readAll returned empty but database '
93-
'exists — silent failure detected, falling back to fss9',
100+
'StorageLocator: fss10 readAll returned empty but prior '
101+
'install data exists (database: '
102+
'${await dbFile.exists()}, hive boxes: $hasLegacyHiveBoxes) '
103+
'— silent failure detected, falling back to fss9',
94104
);
95105
throw Exception(
96106
'FSS10 silent failure: prior install data exists '
97107
'but readAll returned 0 entries',
98108
);
99109
}
100110
log.fine(
101-
'StorageLocator: readAll empty + no database = fresh install',
111+
'StorageLocator: readAll empty + no database or hive boxes = '
112+
'fresh install',
102113
);
103114
}
104115

0 commit comments

Comments
 (0)