From a3cac56c4f7e6afbc5aff98e337c5fc5c1253d9c Mon Sep 17 00:00:00 2001 From: quexeky Date: Sat, 26 Oct 2024 23:23:43 +1100 Subject: [PATCH] More debugging because apparently checksums are the bane of my existence. But it works and I was just an idiot --- desktop/src-tauri/src/downloads/download_logic.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/desktop/src-tauri/src/downloads/download_logic.rs b/desktop/src-tauri/src/downloads/download_logic.rs index 71c7141a..b364959f 100644 --- a/desktop/src-tauri/src/downloads/download_logic.rs +++ b/desktop/src-tauri/src/downloads/download_logic.rs @@ -10,23 +10,28 @@ use urlencoding::encode; pub struct FileWriter { file: File, - hasher: Context + hasher: Context, + data: Vec } impl FileWriter { fn new(path: PathBuf) -> Self { Self { file: OpenOptions::new().write(true).open(path).unwrap(), - hasher: Context::new() + hasher: Context::new(), + data: Vec::new() } } fn finish(mut self) -> Digest { self.flush(); - self.hasher.compute() + let res = self.hasher.compute(); + info!("Final calculated value hash: {:?}", hex::encode(res.0)); + res } } impl Write for FileWriter { fn write(&mut self, buf: &[u8]) -> std::io::Result { self.hasher.write(buf); + self.data.extend_from_slice(buf); self.file.write(buf) }