diff options
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/source/mod.rs | 24 |
2 files changed, 16 insertions, 10 deletions
@@ -42,7 +42,7 @@ shiplift = { git = "https://github.com/softprops/shiplift", rev = "03cc8c0 syntect = "4.4" tar = "0.4" terminal_size = "0.1" -tokio = { version = "0.2", features = ["macros", "fs", "process", "io-util"] } +tokio = { version = "0.2", features = ["macros", "fs", "process", "io-util", "blocking"] } toml = "0.5" typed-builder = "0.7" unindent = "0.1" diff --git a/src/source/mod.rs b/src/source/mod.rs index c2a5bb0..20671bc 100644 --- a/src/source/mod.rs +++ b/src/source/mod.rs @@ -81,18 +81,24 @@ impl SourceEntry { } pub async fn verify_hash(&self) -> Result<()> { - use std::io::Read; let p = self.source_file_path(); - trace!("Reading to buffer: {}", p.display()); - let mut buf = vec![]; - std::fs::OpenOptions::new() - .create(false) - .create_new(false) - .read(true) - .open(&p)? - .read_to_end(&mut buf)?; + + 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??; trace!("Reading to buffer finished: {}", p.display()); self.package_source |