Repository navigation
refactor: reuse the store download and checksum helpers in wright update - #1012
Merged
Merged
Conversation
`wright update` re-implemented the download, size-limit, checksum, and staging logic that wright-driver::store already provides. Route the update path through the shared helpers: - store::client for the HTTPS client (same user agent, 60s timeout) - store::read_limited for the 128 MiB download cap; a body over the limit now reports the existing OverLimit diagnostic instead of a silent truncation that surfaced later as a checksum mismatch - store::verify_sha256 as the single SHA-256 checksum implementation; opy_provider's copy delegates to it and each caller keeps its own diagnostic wording - store::reserve_staging_dir for the update staging directory The store module is now public so wright-cli can use the helpers. A local test server verifies an over-limit update download fails with the size-limit diagnostic and changes nothing. Fixes #1007
Teakowa
approved these changes
Oct 27, 2026
Teakowa
left a comment
Contributor
There was a problem hiding this comment.
LGTM after independent review.
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.
What changed
wright updatere-implemented download, size-limit, checksum, and staging logic thatwright-driver::storealready provides for provider and lint-package downloads. This routes the update path through the shared helpers:store::client(USER_AGENT)replaces the localupdate_clientbuilder (same user agent, same 60 s timeout).store::read_limited(response, MAX_DOWNLOAD_BYTES)replaces the.take(128 MiB).read_to_endcopy. Per the owner decision, an over-limit body now surfaces the existingOverLimitdiagnostic —download from {url} exceeds the 128 MiB size limit— instead of a silent truncation that later failed as a checksum mismatch.store::verify_sha256is now the single SHA-256 checksum verification in the workspace (ChecksumError::{Empty, Invalid, Mismatch}). Bothopy_providerandupdatedelegate to it and keep their caller-specific diagnostic wording.store::reserve_staging_dirreplaces the local staging-dir builder, adding collision retries.wright_driver::storeis nowpubsowright-clican use the helpers; items that remain internal (wright_data_base,promote_dir,PromoteError) stayedpub(crate).Test layout:
tests/update/main.rswas already over the size-guard line limit, so the provider tests moved totests/update/provider.rs(new[[test]]target) and the shared fixtures totests/update/support.rs. Addedan_archive_over_the_size_limit_fails_with_a_limit_error, which serves a 128 MiB + 1 archive from the mock server and asserts exit 4, the size-limit wording, no checksum wording, and an unchanged binary.Verified
cargo test -p wright-cli --test update --test update_provider— 31/31 pass, including the new over-limit test.cargo test -p wright-cli --bin wright— 80/80 unit tests pass.cargo test -p wright-driver --lib— 101/101 pass.cargo test -p wright-driver --test lint_package_store -p wright-cli --test lint_package— pass.cargo fmt --all -- --check,cargo clippy --workspace --all-targets --all-features -- -D warnings,git diff --check— clean.Unverified
WRIGHT_INSTALL_OS), same as before.Fixes #1007