From 5b81ce7d8bb2f7ad947b9293010ba9b27ffcf032 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 19 Jan 2021 13:30:17 +0100 Subject: Fix: Hash verification not async Because we continuously get blocking filesystem operations when the implementation of the verification is async, simply remove the asyncness here now. This does not decrease performance (yet), because the function is called concurrently with other calls anyways. It blocks the tokio worker thread tho, thus maximum parallelism might be = number of cores. :-( Signed-off-by: Matthias Beyer --- src/source/mod.rs | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'src/source') diff --git a/src/source/mod.rs b/src/source/mod.rs index 3c3adea..b356c31 100644 --- a/src/source/mod.rs +++ b/src/source/mod.rs @@ -97,24 +97,20 @@ impl SourceEntry { Ok(()) } - pub async fn verify_hash(&self) -> Result<()> { + pub fn verify_hash(&self) -> Result<()> { + use std::io::Read; + let p = self.source_file_path(); trace!("Reading to buffer: {}", p.display()); let path = p.clone(); - let buf = tokio::task::spawn_blocking(move || { - use std::io::Read; - - let mut buf = vec![]; - std::fs::OpenOptions::new() - .create(false) - .create_new(false) - .read(true) - .open(path)? - .read_to_end(&mut buf) - .map(|_| buf) - }) - .await??; + 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) -- cgit v1.2.3