-
Notifications
You must be signed in to change notification settings - Fork 15
feat: detect checksum files based on file extensions #186
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
Conversation
ee14288
to
020f69a
Compare
Just wondering, haven't looked much into this PR yet, will this conflict with #184? |
#184 makes minimum changes to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ran it locally and it looks good.
% cargo run -- burn duo256_sd.img
Compiling caligula v0.4.8 (/home/astrid/Documents/caligula)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 4.33s
Running `target/debug/caligula burn duo256_sd.img`
Input file: duo256_sd.img
Detected compression format: no compression
> Is this okay? Yes
> Detected hash file duo256_sd.img.sha256 in the directory. Do you want to use it? Yes
Disk image verified successfully!
? Select target disk
> <Refresh devices>
<Show all disks, removable or not>
[Only displaying removable disks.]
I like the feature, but I'd prefer if you just made a separate array for extensions, and separated out the logic accordingly. Something like this:
const HASH_FILES: &[(HashAlg, &str)] = &[
(HashAlg::Md5, "md5sum.txt"),
(HashAlg::Md5, "md5sums.txt"),
(HashAlg::Md5, "MD5SUM"),
...
];
const HASH_EXTENSIONS: &[(HashAlg, &str)] = &[
(HashAlg::Md5, "md5"),
(HashAlg::Sha1, "sha1"),
...
];
pub fn find_hash(input: &Path) -> Option<(HashAlg, String, Vec<u8>)> {
for (alg, hash_file) in HASH_FILES {
...
}
for (alg, hash_file) in HASH_EXTENSIONS {
...
}
}
020f69a
to
9277f7b
Compare
@ifd3f Resolved :) |
Thanks! Will go merge and resolve conflicts when I get the chance. |
Detect checksum files based on file extensions. Closes: ifd3f#181
9277f7b
to
035477a
Compare
@ifd3f Conflicts resolved :) |
Summary
Detect checksum files based on suffixes.
Closes: #181
Type of change
Test plan
todo