fix(firmware): a progress line was being read as a finished download (v0.24.8-beta)
For #141, and the real cause behind #136 and #140. The reporter read the
source and pointed at downloadUpdate() discarding what execute() returns. He
was right, and the consequence was worse than the missing feedback he was
describing.
The orchestrator decided a download had finished with:
if (/downloaded/i.test(status))
RouterOS reports progress as "Downloaded 0% (0.1MiB)" ... "Downloaded 86%
(11.6MiB)". Every one of those matches. Captured on hardware, a poll six
seconds into a download returned "Downloaded 86% (11.6MiB)" — enough to break
out of the wait and restart the device on a partial image. It then came back
on the old firmware and was reported as "rebooted but still reports X — the
update did not apply", which was true, and was ours. Three of his four
complaints were this one bug wearing different clothes.
The command already answers the question. /system/package/update/download
streams a row per progress update — around seventy for a full image — ending
with the outcome. All of it was thrown away and the result inferred by polling
instead.
- downloadUpdate() now returns the parsed outcome and the peak percentage
- completion must say "downloaded ... reboot"; a percentage line is progress
- "New version is available" after the command has run is conclusive: the
download stopped without landing, so it fails immediately rather than
waiting ten minutes to say the same thing more vaguely - the device's own error text is reported verbatim, with how far it got
- each step is logged, so a stalled download shows a percentage that stops
moving instead of ten minutes of silence - an unreadable status is no longer swallowed into "" and treated as "still
downloading"; three consecutive failures end it as lost contact - the reboot message no longer asserts a restart it could not prove. Where
an uptime reading is missing, it says the restart is unknown rather than
stating it as fact
Verified on hardware, both paths, which is what was missing the previous two
times this was declared fixed:
failure — a switch with 1.1 MB free:
downloading 7.23.5 (installed 7.24.2, 1.1 MB free)
download command finished after 49 progress update(s): device reported:
ERROR: connection error - Connection reset by peer
Device could not download 7.23.5: ERROR: connection error - Connection
reset by peer. It reached 85%. The device reports 1.1 MB free.
-> failed in about a minute, no reboot
success — a full 7.24.2 -> 7.23.5 -> 7.24.2 round trip on an AP:
download command finished after 20 progress update(s): downloaded,
awaiting reboot
image confirmed on device; rebooting into 7.23.5
upgraded to 7.23.5
24 tests cover the parser, every string in them captured from a device rather
than imagined, including the assertion that no percentage from 0 to 100 can
ever read as complete.
Co-Authored-By: Claude Opus 5 noreply@anthropic.com
Container image: ghcr.io/2gt-media-group-llc/mikrotik-manager:0.24.8-beta
Documentation: https://2gt-media-group-llc.github.io/mikrotik-manager/