Deduplicate updater helpers and tidy logging #91
Loading…
Reference in a new issue
No description provided.
Delete branch "refactor/updater-shared-helpers"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Code hygiene pass over
updater/andprotocol/versions.py: shares the version/build label formatting between the entity and the updater link, folds the repeated BUSY/ACCEPTED response shapes and node-address parsing in the control API, shares one HTTP response sender between the control API and the file server, drops a couple of stale comments, and makes updater logger names consistent.Commits land one behaviour at a time; see individual messages for the reasoning behind each.
Two things worth a look before merge.
updater/firmware.pyFirmwareCache.images()— the new sort key (version_order(image.version) if image.version is not None else ()) doesn't actually differ in outcome from the oldversion_order(image.version or "").version_ordernever returns anything below-1, and""always parses to(-1,), which compares as the minimum against any real version tuple exactly like()does. Sotest_a_null_version_on_disk_sorts_after_real_versions(tests/test_firmware_cache.py) passes under both the old and new code — I checked by running the old key formula against the test's inputs and got the same sorted order. The comment cleanup (removing the wrong "never fires" claim) is a genuine improvement, but the change isn't a behaviour fix and the added test doesn't lock one down. If there's no real behavioural difference, worth saying so in the commit message instead of implying a fix; if there is a case where they diverge, the test should use it.updater/api.py_session_response— foldingupdate()andflash()into one helper adds"version": versiontoflash()'s ACCEPTED response, defaulting toNone. Previouslyflash()'s response never had aversionkey at all. It's not read by any current caller (custom_components/campervan/firmware.py'sasync_flashonly looks atstarted/reason/detail) and no test pins the payload shape, but it's a small, undocumented widening of the control API's JSON contract that the task description doesn't call out.Everything else —
running_label's buildNone/0unification, the single_node_typeparse in_routeplus_bad_nodeforflash,write_responsestaying inapi.pyto avoid the circular import, and the per-module logger names — checked out against the diff and the test suite.