feat(cli): stream update downloads with live progress - #40
Merged
Conversation
Off-TTY returns null: without \r rewriting, every tick would print its own line into redirected output.
Chunk-wise read replaces buffering the whole asset with arrayBuffer(), hashing incrementally so the binary is never held in memory. TTY output rewrites one status line, and a failed download now closes it, cleans up the staging file, and no longer strands a partial next to the binary.
The guide told users the binary downloads but not what they would see while it did. Also fills the feature map's spec cell for self-update, which had none.
The renderer's return type and downloadAndReplace's parameter declared the same signature under two names. Spec prose loses its em dashes and drops a line reference that went stale when the buffering path was cut.
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.
ignatius updatebuffered the entire ~73MB binary witharrayBuffer()and printed one staticDownloading ignatius <version>…line, so the download looked identical to a hang and peaked at the asset's full size in memory.It now streams the asset chunk-wise to the staging file, counting bytes as they arrive and rewriting one status line in place:
The mechanism is the one
atomicalready ships andnoormalready uses: count bytes off the response body, fire a callback every 512KB. No timer, nostat()polling. sha256 is computed incrementally over the same chunks, so the file is never read twice and never held in memory.Off a TTY the renderer is
nulland one static line prints instead, because without\rrewriting every tick would print its own line into redirected output.Also closes a gap: previously only a rename failure cleaned up the staging file, so a failed or aborted download could strand a partial binary next to the real one. A failed download, a checksum mismatch, and a failed rename now all clean up.
Unchanged, deliberately: checksum verification still runs after the download and before the rename, an unreachable
checksums.txtis still non-fatal, a genuine mismatch still aborts, and Windows still gets the manual-download message.Verification
Full suite green, 1259 assertions. The pure renderer is unit-tested for all five branches.
Beyond that, a real self-update was executed twice against the live GitHub release:
dist/ignatiuswas copied to a throwaway path and ranupdate --yesagainst it. Progress advanced 0% to 100%, the checksum verified, the binary swapped 0.17.0 to 0.19.0 and reported the new version, and no staging file was left behind. The non-TTY path printed one line and no progress output.Not in scope
The download still has no stall watchdog. A bare
fetch()can hang forever if a connection opens and goes silent;atomicandnoormboth abort after 30s of no bytes. Streaming makes that hang more visible but does not fix it. Left out deliberately, since the ask was the indicator, and noted in the branch scratchpad.