summaryrefslogtreecommitdiffstats
path: root/src/source
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-01-12 10:16:20 +0100
committerMatthias Beyer <matthias.beyer@atos.net>2021-01-12 10:17:43 +0100
commit18b256e040881ac674463913b2a7e290125ea738 (patch)
treee1c956a9b12ff6195675ae7611dedf1a2dcdecf0 /src/source
parent63f705792e1e5abf6b8fe9211a10815d3478e21a (diff)
Reimplement hash verification
This patch re-implements hashing using the "ring" crypto library and implementing a streaming hashing with it. This way, we stream the file to the hasher rather than reading the full file to memory. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src/source')
-rw-r--r--src/source/mod.rs12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/source/mod.rs b/src/source/mod.rs
index 20671bc..734b89e 100644
--- a/src/source/mod.rs
+++ b/src/source/mod.rs
@@ -86,24 +86,20 @@ impl SourceEntry {
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![];
+ let reader = tokio::task::spawn_blocking(move || {
std::fs::OpenOptions::new()
.create(false)
.create_new(false)
.read(true)
- .open(path)?
- .read_to_end(&mut buf)
- .map(|_| buf)
+ .open(path)
+ .map(std::io::BufReader::new)
})
.await??;
trace!("Reading to buffer finished: {}", p.display());
self.package_source
.hash()
- .matches_hash_of(&buf)
+ .matches_hash_of(reader)
}
pub async fn create(&self) -> Result<tokio::fs::File> {