Skip to content
This repository was archived by the owner on Feb 17, 2026. It is now read-only.

Commit b487a14

Browse files
committed
fix: hashes_for_file returns wrong result
1 parent 61ca629 commit b487a14

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/utils/hash.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pub async fn digests_for_file(
115115
}
116116

117117
pub async fn hashes_for_file(
118-
path: &str, calc_md5: bool, calc_sha1: bool, calc_sha256: bool, calc_sha3_512: bool,
118+
path: &str, calc_md5: bool, calc_sha1: bool, calc_sha2_256: bool, calc_sha3_512: bool,
119119
) -> Result<(Option<String>, Option<String>, Option<String>, Option<String>), HashError> {
120120
let mut hashers: Vec<Box<dyn DynDigest + Send + Unpin>> = Vec::new();
121121
if calc_md5 {
@@ -124,7 +124,7 @@ pub async fn hashes_for_file(
124124
if calc_sha1 {
125125
hashers.push(Box::new(<sha1::Sha1 as Digest>::new()));
126126
}
127-
if calc_sha256 {
127+
if calc_sha2_256 {
128128
hashers.push(Box::new(<sha2::Sha256 as Digest>::new()));
129129
}
130130
if calc_sha3_512 {
@@ -138,15 +138,15 @@ pub async fn hashes_for_file(
138138
}
139139
if calc_sha1 {
140140
let hash = hashes.remove(0);
141-
result.0 = Some(hash);
141+
result.1 = Some(hash);
142142
}
143-
if calc_sha256 {
143+
if calc_sha2_256 {
144144
let hash = hashes.remove(0);
145-
result.1 = Some(hash);
145+
result.2 = Some(hash);
146146
}
147147
if calc_sha3_512 {
148148
let hash = hashes.remove(0);
149-
result.2 = Some(hash);
149+
result.3 = Some(hash);
150150
}
151151
Ok(result)
152152
}

0 commit comments

Comments
 (0)