Skip to content

Commit

Permalink
change: skip checksum matching for ver 0.4.4 and below
Browse files Browse the repository at this point in the history
  • Loading branch information
MordechaiHadad committed Aug 9, 2024
1 parent 9d85064 commit fe3db0e
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions src/handlers/install_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,28 +131,34 @@ 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 let Some(version) = &version.semver {
if version <= &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?
}
}

Expand Down

0 comments on commit fe3db0e

Please sign in to comment.