Skip to content

Commit

Permalink
switch to a more popular md5 crate
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 committed Jan 10, 2025
1 parent e3a7ebf commit 75caaf6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
12 changes: 8 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ glob = "0.3"
http-range-header = "0.4"
insta = { version = "1", features = ["yaml"] }
libp2p-swarm-test = { workspace = true }
md5 = "0.7"
md-5 = "0.10"
num-bigint = { version = "0.4", features = ['quickcheck'] }
petgraph = "0.7"
predicates = "3"
Expand Down
10 changes: 7 additions & 3 deletions src/tool/subcommands/api_cmd/test_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ mod tests {
use crate::{daemon::db_util::download_to, utils::net::global_http_client};
use directories::ProjectDirs;
use itertools::Itertools as _;
use md5::{Digest as _, Md5};
use url::Url;

#[tokio::test]
Expand Down Expand Up @@ -200,8 +201,11 @@ mod tests {
}

fn get_file_md5_etag(path: &Path) -> Option<String> {
std::fs::read(path)
.ok()
.map(|bytes| format!("{:x}", md5::compute(bytes.as_slice())))
std::fs::read(path).ok().map(|bytes| {
let mut hasher = Md5::new();
hasher.update(bytes.as_slice());
let hash = hasher.finalize();
format!("{hash:x}")
})
}
}

0 comments on commit 75caaf6

Please sign in to comment.