Skip to content

Fix digest command to support remote URLs#70

Merged
digizeph merged 1 commit intomainfrom
dev/fix-digest-remote-urls
Mar 29, 2026
Merged

Fix digest command to support remote URLs#70
digizeph merged 1 commit intomainfrom
dev/fix-digest-remote-urls

Conversation

@digizeph
Copy link
Copy Markdown
Member

Summary

Fixed the "digest" CLI command and get_sha256_digest() library function to work with remote URLs (HTTP, HTTPS, FTP, S3), not just local files.

Problem

The oneio digest command was failing with "No such file or directory" error when provided with a remote URL:

$ oneio digest https://example.com/file.tar.gz
digest error: IO error: No such file or directory (os error 2)

Root Cause

get_sha256_digest() in src/digest.rs was using std::fs::File::open() which only works with local file paths. It did not support remote URLs that the rest of the oneio library handles.

Solution

Changed get_sha256_digest() to use OneIo::new()?.get_reader_raw(path)? instead of std::fs::File::open(path), which:

  • Supports both local files and remote URLs
  • Uses raw reader without decompression to ensure the hash matches the actual file bytes

Changes

  • src/digest.rs: Use OneIo::get_reader_raw() instead of std::fs::File::open()
  • CHANGELOG.md: Added entry under "Unreleased" section

Verification

After the fix:

$ oneio digest https://github.com/bgpkit/asninfo/releases/download/v0.4.3/asninfo-universal-apple-darwin.tar.gz
9ee71b231224a8162d3a0f9b607b378336262bf38e1433d983d26823e2d3b16b

$ curl -sL https://github.com/bgpkit/asninfo/... | shasum -a 256
9ee71b231224a8162d3a0f9b607b378336262bf38e1433d983d26823e2d3b16b  -

Both hashes match, confirming the fix works correctly.

Related Issue

Fixes #69

Changed get_sha256_digest() to use OneIo::get_reader_raw() instead of
std::fs::File::open(), enabling SHA256 hash calculation for both local
files and remote URLs (HTTP, HTTPS, FTP, S3).

Fixes #69
@digizeph digizeph enabled auto-merge March 29, 2026 01:05
@digizeph digizeph merged commit b530a91 into main Mar 29, 2026
5 checks passed
@digizeph digizeph deleted the dev/fix-digest-remote-urls branch March 29, 2026 01:11
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.

CLI digest command fails on remote URLs

1 participant