feat: add opt-in progress callback to GetFlashMD5 - #51
Merged
Conversation
- add trailing ProgressFunc param to GetFlashMD5 - nil preserves today's exact behavior, no goroutine spun up - non-nil ticks a synthetic ETA (elapsed/estimated ms) every 500ms against the existing size-scaled md5TimeoutForSize timeout, since the device stays silent for the duration of the hash computation - extract md5TimeoutForSize in protocol.go from flashMD5's inline calc so both the real command timeout and the ticker estimate share one formula - extract tickMD5 helper with an injectable interval for fast unit tests - final progress call only fires on success; ticker goroutine is always joined before returning and never touches the connection - generalize the ProgressFunc doc comment to note operation-defined units - update the existing call site in flasher_test.go - add tests: tickMD5 direct (monotonic ticks, final call, error path, panic path, no goroutine leak) plus end-to-end wiring through the mock connection
Member
|
More progress! 😄 Thanks for the addition @jgangemi now merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in
ProgressFunctoGetFlashMD5, completing progress-callback coverage for the long-running flash operations (flash, erase, and read already report progress).Like whole-chip erase, an on-device MD5 is a single blocking command — the device stays silent until the digest is ready, so there is no per-chunk protocol seam for byte-accurate progress. This reports a synthetic ETA (elapsed / estimated-total milliseconds) ticked against the size-scaled MD5 timeout, matching the
ProgressFuncconvention already used byEraseFlash/EraseRegion.Behavior
progress == nil→ unchanged; no goroutine is spawned (opt-in cost only).(est, est)only on success.ProgressFunccall sites.Tests
(est, est), monotonic and capped; the error path omits the final tick; the ticker joins on success, error, and panic; and an intermediate-callback panic is dropped without crashing.