fix(companion): restore the v1.27 -> v1.28 scope migrations

eed6d31d dropped two one-time migrations as "old cruft", but both are needed
by exactly the upgrade path this release ships: v1.27 has sentinel 0xC0DE002A
and the scope list is new in this cycle.

- loadScopeList() again turns an existing single default_scope_name/key into
  list entry 1 (default) and MyMesh::begin() seeds the channels that already
  exist with it. Without it an upgrader's DMs and channels silently go out
  unscoped, contradicting the release note.
- loadPrefsInt() again zeroes repeat_extra_scope_mask/ch_scope_idx when the
  file predates 0xC0DE002B, so the old sentinel tail can't read back as real
  scope picks.

The older-than-v1.27 backfills stay removed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-09-19 13:19:46 +02:00
co-authored by Claude Sonnet 5
parent 745aefcee1
commit dff56a3c53
3 changed files with 82 additions and 28 deletions
+14 -4
View File
@@ -46,10 +46,20 @@ public:
// deleted slot is simply absent from the file, not written as empty).
bool loadChannels(DataStoreHost* host);
void saveChannels(DataStoreHost* host);
// /scopes1: the shared named-scope list (see ScopeList.h). A device with no
// file yet just starts with the default-constructed ScopeList (empty,
// default_idx 0 == "*").
void loadScopeList(ScopeList& list);
// /scopes1: the shared named-scope list (see ScopeList.h). `prefs` is only
// read, for a one-time migration of a pre-existing single
// default_scope_name/key into list entry 1 -- the file is authoritative
// once it exists.
//
// Returns true ONLY when that legacy migration just ran, i.e. this boot is
// the first on a device that had a Scope configured the old way. The caller
// uses that to seed the channels that already exist with the migrated entry
// (see MyMesh::begin) -- channels carry their own scope now, so without the
// seed an upgrader's channel traffic would silently drop to unscoped even
// though their DMs kept the old scope. Returns false when /scopes1 was
// already there, and on a genuinely fresh device with nothing to migrate
// (list left empty, default_idx 0 == "*").
bool loadScopeList(ScopeList& list, const NodePrefs& prefs);
void saveScopeList(const ScopeList& list);
void migrateToSecondaryFS();
uint8_t getBlobByKey(const uint8_t key[], int key_len, uint8_t dest_buf[]);