Repository navigation
feat(download): opensource internal download library - #88
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Critical download defects remain in archive checksum verification, temporary-file isolation, decompression limits, and cache-directory creation, causing valid downloads to fail or exceed safety limits.
9 open issues
Use unique temporary files for concurrent downloads · New Apply the extraction limit before filtering archive entries · New Drain the compressed archive before verifying its checksum · New Create the cache directory before downloading · New Close and remove temporary files on download failures · New Close output and archive handles when extraction fails · New Treat scheme-less checksum sources as local paths · New Bound checksum response size · New Select the checksum entry for the downloaded asset · New
What changed in this PR
Adds a reusable download package to cloudctl, laying the groundwork for automatic tool installation and caching described in #71.
Changes:
- Adds binary, tar.gz, and ZIP downloads with SHA-256 verification, progress output, and size-limit checks.
- Adds GitHub release downloads that prefer API digests, fall back to
.sha256files, and reuse cached binaries. - Introduces shared XDG cache configuration and supporting dependencies.
| File | Description |
|---|---|
pkg/download/github.go |
Implements GitHub digest lookup, checksum fallback, and cached release downloads. |
pkg/download/download.go |
Implements download, extraction, checksum verification, and progress helpers. |
pkg/config/constants.go |
Defines the user agent and application-specific XDG locations. |
go.sum |
Records checksums for added dependencies. |
go.mod |
Adds dependencies for XDG paths, progress formatting, and logging. |
Review effort: Balanced
Signed-off-by: Piotr Skamruk <piotr.skamruk@gmail.com>
29fd35e to
1c68757
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Critical download defects block normal cache downloads, can cache an unrelated ZIP entry, and allow gzip decompression beyond the extraction limit.
4 open issues
9 resolved since last review
Create the cache directory before downloading Drain the compressed archive before verifying its checksum Apply the extraction limit before filtering archive entries Use unique temporary files for concurrent downloads Select the checksum entry for the downloaded asset Bound checksum response size Treat scheme-less checksum sources as local paths Close output and archive handles when extraction fails Close and remove temporary files on download failures
Review effort: Balanced
8afaa79 to
9566dac
Compare
There was a problem hiding this comment.
🟡 Changes recommended
A shadowed output handle causes valid archive downloads to panic, while cross-filesystem staging, incorrect checksum selection, and premature cache publication can also leave downloads unusable.
3 open issues
4 resolved since last review
Review effort: Balanced
Signed-off-by: Piotr Skamruk <piotr.skamruk@gmail.com>
There was a problem hiding this comment.
🟡 Changes recommended
Shared checksum manifests select the first digest instead of the downloaded asset’s entry, causing valid downloads to fail verification across all three download functions.
1 open issue
3 resolved since last review
Review effort: Balanced
Dependency ModernizationThree new dependencies added in this PR are worth revisiting before merge.
|
Code ReviewCritical:
|
|
|
Double close and rename is not a problem. Both will return an error which is explicitly ignored. They were added as there was no code which would handle cleanup if there was a premature return from the loop. |
Which filesystem/OS? |
|
Good point about |
Signed-off-by: Piotr Skamruk <piotr.skamruk@gmail.com>
|
|
|
@jellonek if you could resolve the open conversation #88 (review) we can merge it |



Closes #71