Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions tools/packager/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ struct ReleaseDirectories {
examples_dir: PathBuf,
}

struct HashWriter<'a>(&'a mut Sha256);

impl<'a> std::io::Write for HashWriter<'a> {
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
self.0.update(buf);
Ok(buf.len())
}

fn flush(&mut self) -> std::io::Result<()> {
Ok(())
}
}

fn main() -> anyhow::Result<()> {
println!("=== Starting TechScript 2.0 Packaging Pipeline ===");

Expand Down Expand Up @@ -726,9 +739,7 @@ fn calculate_checksums_json(release_dir: &Path) -> anyhow::Result<serde_json::Va
if fpath.exists() {
let mut file = File::open(&fpath)?;
let mut hasher = Sha256::new();
let mut buffer = Vec::new();
file.read_to_end(&mut buffer)?;
hasher.update(&buffer);
std::io::copy(&mut file, &mut HashWriter(&mut hasher))?;
let hash = hasher.finalize();
map.insert(
fname.to_string(),
Expand All @@ -749,9 +760,7 @@ fn calculate_checksums_json(release_dir: &Path) -> anyhow::Result<serde_json::Va
if fpath.exists() {
let mut file = File::open(&fpath)?;
let mut hasher = Sha256::new();
let mut buffer = Vec::new();
file.read_to_end(&mut buffer)?;
hasher.update(&buffer);
std::io::copy(&mut file, &mut HashWriter(&mut hasher))?;
let hash = hasher.finalize();
map.insert(
fname.to_string(),
Expand Down Expand Up @@ -788,9 +797,7 @@ fn generate_checksums_txt(release_dir: &Path) -> anyhow::Result<()> {
if file_path.exists() {
let mut file = File::open(file_path)?;
let mut hasher = Sha256::new();
let mut buffer = Vec::new();
file.read_to_end(&mut buffer)?;
hasher.update(&buffer);
std::io::copy(&mut file, &mut HashWriter(&mut hasher))?;
let hash = hasher.finalize();

// Format to show filename relative to the release root
Expand Down
Loading