diff options
author | Matthias Beyer <matthias.beyer@atos.net> | 2021-01-19 13:30:17 +0100 |
---|---|---|
committer | Matthias Beyer <matthias.beyer@atos.net> | 2021-01-19 15:31:07 +0100 |
commit | 5b81ce7d8bb2f7ad947b9293010ba9b27ffcf032 (patch) | |
tree | 0e1ef8f14c07e0a0d1af710e48c452d4150146ac /src | |
parent | 93bc626a7d5b82cc4dba00776a1832e1ea79889a (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')
-rw-r--r-- | src/commands/source.rs | 2 | ||||
-rw-r--r-- | src/source/mod.rs | 24 |
2 files changed, 11 insertions, 15 deletions
diff --git a/src/commands/source.rs b/src/commands/source.rs index daf3617..2687e8b 100644 --- a/src/commands/source.rs +++ b/src/commands/source.rs @@ -95,7 +95,7 @@ where let bar = multi.add(progressbars.bar()); if source.path().exists() { trace!("Exists: {}", source.path().display()); - source.verify_hash().await.with_context(|| { + source.verify_hash().with_context(|| { anyhow!("Hash verification failed for: {}", source.path().display()) })?; 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) |