fix(train): only the firmware version the person agreed to is written (ADR 0030, D55)

Relayed by the instance, the version asked again before downloading was written even where it wasn't the one shown and agreed to, and the band recorded as at the agreed one. Another version now writes nothing and is offered instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-30 12:55:42 +01:00
commit ac6cff179f
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -297,6 +297,14 @@ class PolarLoop(
_update(_with(_status.loop!.copyWith(firmwareOffered: () => null)));
throw const LoopFailed('no update');
}
// Only the version the person agreed to is written: another one
// offered since is offered to them instead.
if (offered != version) {
_update(
_with(_status.loop!.copyWith(firmwareOffered: () => offered)),
);
throw const LoopFailed('another update');
}
final bytes = await _relayed(
() =>
relay.download(hardwareCode: info.hardwareCode, version: offered),