Skip to content

versions: fetch, a download in a directory only as the bytes it pins - #80

Merged
aledbf merged 3 commits into
mainfrom
versions/fetch
Nov 8, 2026
Merged

aledbf merged 3 commits into
mainfrom
versions/fetch

Conversation

@aledbf

@aledbf aledbf commented Nov 8, 2026

Copy link
Copy Markdown
Member

go tool versions fetch <name> <dir> puts a download entry's file in dir, named as its URL names it, and prints the path (upstream.PinnedFile).

  • A file already there is checked every time and kept when it is the pin; one that is not (cut short, replaced) is downloaded again.
  • A download that is not the pin is refused. It is written to a .part beside the file and renamed only once it matches, so a refusal leaves nothing.
  • Pinned is the same check held in memory; this one streams, for a 150 MB tarball. sha256Of is now download into io.Discard, one copy of the read-and-hash.

spin writes this twice in shell, in hack/stores' fetch() and in tools:shellcheck (curl, versions env, sed, sha256sum -c); a spin PR replaces both once this is tagged.

Checked: tests for fresh, cached (no download), replaced, refused and refused-over-a-cached-file, and the command against a TLS server. mutate -base origin/main: 37 refused, 0 survived. Against spin's versions.yaml: victoriametrics fetched, fetched again from the cache, and a corrupted cache replaced; the sha256 is the pin.

Lint's vulngate is red on main for an unrelated advisory; #78 fixes it.

🤖 Generated with Claude Code

aledbf and others added 3 commits November 8, 2026 01:21
`go tool versions fetch <name> <dir>` puts a download entry's file in dir, named as its URL names
it, and prints the path (upstream.PinnedFile). A file already there is checked every time and kept
when it is the pin; one that is not is downloaded again; a download that is not the pin is refused,
written beside the file and never renamed into place, so nothing is left. Pinned is the same check
held in memory; this one streams, for a store's tarball of 150 MB.

spin wrote it twice in shell - hack/stores' fetch() and tools:shellcheck - as curl, `versions env`,
sed and `sha256sum -c`. sha256Of is download into io.Discard now, one copy of the read-and-hash.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aledbf
aledbf merged commit e0d00ca into main Nov 8, 2026
3 checks passed
@aledbf
aledbf deleted the versions/fetch branch November 8, 2026 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant