diff options
Diffstat (limited to 'src/source/mod.rs')
-rw-r--r-- | src/source/mod.rs | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/source/mod.rs b/src/source/mod.rs index b356c31..1c97a87 100644 --- a/src/source/mod.rs +++ b/src/source/mod.rs @@ -97,23 +97,24 @@ impl SourceEntry { Ok(()) } - pub fn verify_hash(&self) -> Result<()> { - use std::io::Read; - + pub async fn verify_hash(&self) -> Result<()> { let p = self.source_file_path(); - trace!("Reading to buffer: {}", p.display()); + trace!("Verifying : {}", p.display()); let path = p.clone(); - let mut buf = vec![]; - std::fs::OpenOptions::new() - .create(false) - .create_new(false) - .read(true) - .open(path)? - .read_to_end(&mut buf)?; - - trace!("Reading to buffer finished: {}", p.display()); - self.package_source.hash().matches_hash_of(&buf) + let reader = tokio::task::spawn_blocking(move || { + std::fs::OpenOptions::new() + .create(false) + .create_new(false) + .read(true) + .open(path) + .map(std::io::BufReader::new) + }) + .await??; + + self.package_source + .hash() + .matches_hash_of(reader) } pub async fn create(&self) -> Result<tokio::fs::File> { |