From 4ce06a16bc6010edda366cecc0f1de257e9796aa Mon Sep 17 00:00:00 2001 From: DecDuck Date: Sun, 19 Jan 2025 22:22:55 +1100 Subject: [PATCH] feat(downloads): re-enable checksums --- .../src-tauri/src/games/downloads/download_logic.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/desktop/src-tauri/src/games/downloads/download_logic.rs b/desktop/src-tauri/src/games/downloads/download_logic.rs index fa5372f7..ea89c5cc 100644 --- a/desktop/src-tauri/src/games/downloads/download_logic.rs +++ b/desktop/src-tauri/src/games/downloads/download_logic.rs @@ -10,7 +10,7 @@ use md5::{Context, Digest}; use reqwest::blocking::{RequestBuilder, Response}; use std::fs::{set_permissions, Permissions}; -use std::io::Read; +use std::io::{ErrorKind, Read}; #[cfg(unix)] use std::os::unix::fs::PermissionsExt; use std::{ @@ -39,19 +39,17 @@ impl DropWriter { // Write automatically pushes to file and hasher impl Write for DropWriter { fn write(&mut self, buf: &[u8]) -> io::Result { - /* self.hasher.write_all(buf).map_err(|e| { io::Error::new( ErrorKind::Other, format!("Unable to write to hasher: {}", e), ) })?; - */ self.destination.write(buf) } fn flush(&mut self) -> io::Result<()> { - // self.hasher.flush()?; + self.hasher.flush()?; self.destination.flush() } } @@ -179,16 +177,15 @@ pub fn download_game_chunk( set_permissions(ctx.path.clone(), permissions).unwrap(); } - /* + let checksum = pipeline .finish() - .map_err(|e| GameDownloadError::IoError(e))?; + .map_err(|e| ApplicationDownloadError::IoError(e.kind()))?; let res = hex::encode(checksum.0); if res != ctx.checksum { - return Err(GameDownloadError::Checksum); + return Err(ApplicationDownloadError::Checksum); } - */ Ok(true) }