summaryrefslogtreecommitdiffstats
path: root/src/source
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-01-19 13:30:17 +0100
committerMatthias Beyer <matthias.beyer@atos.net>2021-01-19 15:31:07 +0100
commit5b81ce7d8bb2f7ad947b9293010ba9b27ffcf032 (patch)
tree0e1ef8f14c07e0a0d1af710e48c452d4150146ac /src/source
parent93bc626a7d5b82cc4dba00776a1832e1ea79889a (diff)
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 <matthias.beyer@atos.net>
Diffstat (limited to 'src/source')
-rw-r--r--src/source/mod.rs24
1 files changed, 10 insertions, 14 deletions
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)