Fix digest command to support remote URLs#70
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 digestcommand was failing with "No such file or directory" error when provided with a remote URL:Root Cause
get_sha256_digest()insrc/digest.rswas usingstd::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 useOneIo::new()?.get_reader_raw(path)?instead ofstd::fs::File::open(path), which:Changes
src/digest.rs: UseOneIo::get_reader_raw()instead ofstd::fs::File::open()CHANGELOG.md: Added entry under "Unreleased" sectionVerification
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