Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch: support specifying hash on the CLI #21589

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

matklad
Copy link
Contributor

@matklad matklad commented Oct 4, 2024

If you use zig fetch as a curl, you might want to provide it with the expected hash up-front, to skip the download work if the resource is already cached, and to otherwise verify the resource integrity.

Example usage:

λ /usr/bin/time zig-out/bin/zig fetch https://github.com/tigerbeetle/tigerbeetle/releases/download/0.16.5/tigerbeetle-universal-macos.zip
12209a8b1468572b678c8949f114633b2e25fe08132d19d9edcf6263e081fd550217
        3.01 real         1.41 user         0.08 sys
matklad@ahab ~/p/zig (master)
λ /usr/bin/time zig-out/bin/zig fetch https://github.com/tigerbeetle/tigerbeetle/releases/download/0.16.5/tigerbeetle-universal-macos.zip 12209a8b1468572b678c8949f114633b2e25fe08132d19d9edcf6263e081fd550217
12209a8b1468572b678c8949f114633b2e25fe08132d19d9edcf6263e081fd550217
        0.00 real         0.00 user         0.00 sys
matklad@ahab ~/p/zig (master)
λ /usr/bin/time zig-out/bin/zig fetch https://github.com/tigerbeetle/tigerbeetle/releases/download/0.16.5/tigerbeetle-universal-macos.zip 12209a8b1468572b678c8949f114633b2e25fe08132d19d9edcf6263e081fd550218
error: hash mismatch: manifest declares 12209a8b1468572b678c8949f114633b2e25fe08132d19d9edcf6263e081fd550218 but the fetched package has 12209a8b1468572b678c8949f114633b2e25fe08132d19d9edcf6263e081fd550217
        2.39 real         1.39 user         0.09 sys
matklad@ahab ~/p/zig (master) [1]
λ

If you use `zig fetch` as a `curl`, you might want to provide it with
the expected hash up-front, to skip the download work if the resource is
already hash, and to otherwise verify the resource integrity.

Example usage:

```
λ /usr/bin/time zig-out/bin/zig fetch https://github.com/tigerbeetle/tigerbeetle/releases/download/0.16.5/tigerbeetle-universal-macos.zip
12209a8b1468572b678c8949f114633b2e25fe08132d19d9edcf6263e081fd550217
        3.01 real         1.41 user         0.08 sys
matklad@ahab ~/p/zig (master)
λ /usr/bin/time zig-out/bin/zig fetch https://github.com/tigerbeetle/tigerbeetle/releases/download/0.16.5/tigerbeetle-universal-macos.zip 12209a8b1468572b678c8949f114633b2e25fe08132d19d9edcf6263e081fd550217
12209a8b1468572b678c8949f114633b2e25fe08132d19d9edcf6263e081fd550217
        0.00 real         0.00 user         0.00 sys
matklad@ahab ~/p/zig (master)
λ /usr/bin/time zig-out/bin/zig fetch https://github.com/tigerbeetle/tigerbeetle/releases/download/0.16.5/tigerbeetle-universal-macos.zip 12209a8b1468572b678c8949f114633b2e25fe08132d19d9edcf6263e081fd550218
error: hash mismatch: manifest declares 12209a8b1468572b678c8949f114633b2e25fe08132d19d9edcf6263e081fd550218 but the fetched package has 12209a8b1468572b678c8949f114633b2e25fe08132d19d9edcf6263e081fd550217
        2.39 real         1.39 user         0.09 sys
matklad@ahab ~/p/zig (master) [1]
λ
```
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