Skip to content

refactor: reuse the store download and checksum helpers in wright update - #1012

Merged
e54-bot merged 1 commit into
mainfrom
gh-1007-update-store-helpers
Oct 27, 2026
Merged

e54-bot merged 1 commit into
mainfrom
gh-1007-update-store-helpers

Conversation

@e54-bot

@e54-bot e54-bot commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

What changed

wright update re-implemented download, size-limit, checksum, and staging logic that wright-driver::store already provides for provider and lint-package downloads. This routes the update path through the shared helpers:

  • store::client(USER_AGENT) replaces the local update_client builder (same user agent, same 60 s timeout).
  • store::read_limited(response, MAX_DOWNLOAD_BYTES) replaces the .take(128 MiB).read_to_end copy. Per the owner decision, an over-limit body now surfaces the existing OverLimit diagnostic — download from {url} exceeds the 128 MiB size limit — instead of a silent truncation that later failed as a checksum mismatch.
  • store::verify_sha256 is now the single SHA-256 checksum verification in the workspace (ChecksumError::{Empty, Invalid, Mismatch}). Both opy_provider and update delegate to it and keep their caller-specific diagnostic wording.
  • store::reserve_staging_dir replaces the local staging-dir builder, adding collision retries.
  • wright_driver::store is now pub so wright-cli can use the helpers; items that remain internal (wright_data_base, promote_dir, PromoteError) stayed pub(crate).

Test layout: tests/update/main.rs was already over the size-guard line limit, so the provider tests moved to tests/update/provider.rs (new [[test]] target) and the shared fixtures to tests/update/support.rs. Added an_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

  • Windows/macOS update paths were exercised by the existing Linux-hosted tests via env overrides only (WRIGHT_INSTALL_OS), same as before.

Fixes #1007

`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
@e54-bot
e54-bot merged commit eb42f1f into main Oct 27, 2026
36 checks passed
@e54-bot
e54-bot deleted the gh-1007-update-store-helpers branch October 27, 2026 11:06
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Make Workshop Great Again Oct 27, 2026

@Teakowa Teakowa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after independent review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Reuse the store download and checksum helpers in wright update

2 participants