diff --git a/src/blake3.rs b/src/blake3.rs index 746b829d1..0ac193180 100644 --- a/src/blake3.rs +++ b/src/blake3.rs @@ -21,3 +21,11 @@ pub fn blake3_progress>(path: P) -> Result { Ok(res) } + +pub fn blake3_silent>(path: P) -> Result { + let mut f = fs::File::open(&path)?; + + let hash = Hasher::new().update_reader(&mut f)?.finalize(); + let res = format!("{}", hash.to_hex()); + Ok(res) +} diff --git a/src/cook/fetch.rs b/src/cook/fetch.rs index c076d4e2d..bb950ac44 100644 --- a/src/cook/fetch.rs +++ b/src/cook/fetch.rs @@ -3,13 +3,18 @@ use crate::cook::fs::*; use crate::cook::script::*; use crate::is_redox; use crate::recipe::Recipe; -use crate::{blake3::blake3_progress, recipe::SourceRecipe}; +use crate::{blake3, recipe::SourceRecipe}; use std::fs; use std::path::{Path, PathBuf}; use std::process::Command; -pub(crate) fn get_blake3(path: &PathBuf) -> Result { - blake3_progress(&path).map_err(|err| { +pub(crate) fn get_blake3(path: &PathBuf, show_progress: bool) -> Result { + if show_progress { + blake3::blake3_progress(&path) + } else { + blake3::blake3_silent(&path) + } + .map_err(|err| { format!( "failed to calculate blake3 of '{}': {}\n{:?}", path.display(), @@ -52,7 +57,7 @@ pub fn fetch_offline(recipe_dir: &Path, source: &Option) -> Result }) => { if !source_dir.is_dir() { let source_tar = recipe_dir.join("source.tar"); - let source_tar_blake3 = get_blake3(&source_tar)?; + let source_tar_blake3 = get_blake3(&source_tar, true)?; if source_tar.exists() { if let Some(blake3) = blake3 { if source_tar_blake3 != *blake3 { @@ -237,7 +242,7 @@ pub fn fetch(recipe_dir: &Path, source: &Option) -> Result