From e7744ce9ee3ccb2a7c86fc77a3b45ca0122331eb Mon Sep 17 00:00:00 2001 From: morde Date: Fri, 9 Aug 2024 12:42:12 +0300 Subject: [PATCH] change: skip checksum matching for ver 0.4.4 and below debug info more debug info ..... corrected if statement remove debug statement, i need to squash these commits --- src/handlers/install_handler.rs | 36 ++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/handlers/install_handler.rs b/src/handlers/install_handler.rs index a6feb6a..d1b3e21 100644 --- a/src/handlers/install_handler.rs +++ b/src/handlers/install_handler.rs @@ -131,28 +131,32 @@ pub async fn start( }?; if let PostDownloadVersionType::Standard(downloaded_archive) = downloaded_archive { - let downloaded_checksum = download_version(client, version, root, config, true).await?; - - if let PostDownloadVersionType::Standard(downloaded_checksum) = downloaded_checksum { - let mut archive_path = root - .join(&downloaded_archive.file_name); + if version.semver.is_some() && version.semver.as_ref().unwrap() <= &Version::new(0, 4, 4) { + unarchive::start(downloaded_archive).await? + } else { + let downloaded_checksum = download_version(client, version, root, config, true).await?; - archive_path.set_file_name(format!("{}.{}", archive_path.file_name().unwrap().to_string_lossy(), downloaded_archive.file_format)); + if let PostDownloadVersionType::Standard(downloaded_checksum) = downloaded_checksum { + let archive_path = root.join(format!( + "{}.{}", + downloaded_archive.file_name, downloaded_archive.file_format + )); - let mut checksum_path = root - .join(&downloaded_checksum.file_name); + let checksum_path = root.join(format!( + "{}.{}", + downloaded_checksum.file_name, downloaded_checksum.file_format + )); - checksum_path.set_file_name(format!("{}.{}", checksum_path.file_name().unwrap().to_string_lossy(), downloaded_checksum.file_format)); + if !sha256cmp(&archive_path, &checksum_path)? { + tokio::fs::remove_file(archive_path).await?; + tokio::fs::remove_file(checksum_path).await?; + return Err(anyhow!("Checksum mismatch!")); + } - if !sha256cmp(&archive_path, &checksum_path)? { - tokio::fs::remove_file(archive_path).await?; + info!("Checksum matched!"); tokio::fs::remove_file(checksum_path).await?; - return Err(anyhow!("Checksum mismatch!")); + unarchive::start(downloaded_archive).await? } - - info!("Checksum matched!"); - tokio::fs::remove_file(checksum_path).await?; - unarchive::start(downloaded_archive).await? } }