Skip to content

Commit efdff4f

Browse files
committed
chore: minor adaptions to new deps
1 parent 99307a3 commit efdff4f

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

src/write_once_service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl WriteOnceService {
2020
}
2121

2222
pub fn hash_key(path: &str) -> String {
23-
format!("locks:{:x}", Sha256::digest(path.as_bytes()))
23+
format!("locks:{}", hex::encode(Sha256::digest(path.as_bytes())))
2424
}
2525
pub async fn lock(&self, path: &str) -> Result<bool, String> {
2626
let key = Self::hash_key(path);

tests/helpers/mod.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,8 @@ pub fn add_a_key(keyring_path: &str, password: &str) -> assert_cmd::assert::Asse
237237
pub fn compute_sha256(file_path: &str) -> String {
238238
use data_encoding::HEXLOWER;
239239
use sha2::{Digest, Sha256};
240-
use std::{fs, io};
240+
use std::fs;
241241

242-
let mut file = fs::File::open(file_path).unwrap();
243-
let mut hasher = Sha256::new();
244-
let _n = io::copy(&mut file, &mut hasher).unwrap();
245-
HEXLOWER.encode(&hasher.finalize()[..])
242+
let bytes = fs::read(file_path).unwrap();
243+
HEXLOWER.encode(&Sha256::digest(&bytes)[..])
246244
}

0 commit comments

Comments
 (0)