mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-18 20:09:10 +00:00
Merge pull request #420 from spacedriveapp/cas-hotfix
hotfix: re-import `cas.rs` from `eng-245`
This commit is contained in:
commit
2700a87b28
|
@ -44,23 +44,5 @@ pub async fn generate_cas_id(path: PathBuf, size: u64) -> Result<String, io::Err
|
|||
|
||||
let hex = hasher.finalize().to_hex();
|
||||
|
||||
Ok(hex)
|
||||
}
|
||||
|
||||
pub async fn full_checksum(path: &str) -> Result<String, io::Error> {
|
||||
const BLOCK_SIZE: usize = 1048576;
|
||||
//read file as buffer and convert to digest
|
||||
let mut reader = File::open(path).await?;
|
||||
let mut context = Hasher::new();
|
||||
let mut buffer = [0; 1048576];
|
||||
loop {
|
||||
let read_count = reader.read(&mut buffer).await?;
|
||||
context.update(&buffer[..read_count]);
|
||||
if read_count != BLOCK_SIZE {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let hex = to_hex_string(context.finalize().as_bytes());
|
||||
|
||||
Ok(hex)
|
||||
Ok(hex.to_string())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue