Skip to content

Commit

Permalink
fix: Support other sha256 checksum file formats. (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj authored Nov 20, 2023
1 parent 2fe32c2 commit 80f0930
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
- [Rust](https://github.com/moonrepo/rust-plugin/blob/master/CHANGELOG.md)
- [TOML schema](https://github.com/moonrepo/schema-plugin/blob/master/CHANGELOG.md)

## Unreleased

#### 🐞 Fixes

- Fixed an issue where checksum verification would fail if the `.sha256` file prefixed the file name with `*`.

## 0.23.1

#### 🐞 Fixes
Expand Down
9 changes: 6 additions & 3 deletions crates/core/src/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,16 +681,19 @@ impl Tool {
}
_ => {
let checksum_hash = hash_file_contents(download_file)?;
let checksum_matching_line =
format!("{} {}", checksum_hash, fs::file_name(download_file));
let download_file_name = fs::file_name(download_file);

for line in BufReader::new(fs::open_file(checksum_file)?)
.lines()
.flatten()
{
// <checksum> <file>
// <checksum> *<file>
// <checksum>
if line == checksum_matching_line || line == checksum_hash {
if line == checksum_hash
|| (line.starts_with(&checksum_hash)
&& line.ends_with(&download_file_name))
{
verified = true;
break;
}
Expand Down

0 comments on commit 80f0930

Please sign in to comment.