Stamp legacy images inside the migration; hold early channel frames

- Image entries are stamped with their channel ID before the migration is
  marked done, so an interrupted run repeats it instead of leaving them
  unstamped (and invisible) forever.
- Channel message/data frames that arrive before this session's slot map
  is confirmed are held and replayed once it is. Current firmware only
  sends them in reply to SYNC_NEXT_MESSAGE, which already waits; this
  guards against a stale saved map filing them under the wrong channel.
This commit is contained in:
zjs81 committed 2026-10-11 18:04:53 -07:00
1 parent 679116ed03
commit 6a8df764bb
4 files changed
+87 -5

No files matched your search

@@ -254,6 +254,27 @@ void main() {
);
});
test('images are stamped before the migration is marked done', () async {
await _init(legacyValues());
await expectLater(
ChannelStorageMigration.migrate(
_scopeA,
beforeDone: (_) async => throw StateError('killed'),
),
throwsStateError,
);
// Not marked done, so the next launch stamps again.
Map<int, String>? stamped;
await ChannelStorageMigration.migrate(
_scopeA,
beforeDone: (slotIds) async => stamped = slotIds,
);
expect(stamped, {0: _idOne, 2: _idTwo});
// Data moved by the first run is still there.
final messages = ChannelMessageStore()..setPublicKeyHex = _deviceA;
expect((await messages.loadChannelMessages(_idOne)).single.text, 'hello');
});
test('skips a scope that must not adopt legacy data', () async {
await _init(legacyValues());
scopesWithoutLegacyMigration.add(_scopeA);