More progress on checksums

This commit is contained in:
quexeky
2024-10-26 15:18:34 +11:00
parent 714b968683
commit c51e7618bd
3 changed files with 17 additions and 14 deletions

12
src-tauri/Cargo.lock generated
View File

@ -1699,11 +1699,11 @@ dependencies = [
[[package]]
name = "gxhash"
version = "3.4.1"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a197c9b654827513cf53842c5c6d3da2b4b35a785f8e0eff78bdf8e445aba1bb"
checksum = "09f0c897148ec6ff3ca864b7c886df75e6ba09972d206bd9a89af0c18c992253"
dependencies = [
"rustversion",
"rand 0.8.5",
]
[[package]]
@ -3420,12 +3420,6 @@ dependencies = [
"untrusted",
]
[[package]]
name = "rustversion"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248"
[[package]]
name = "ryu"
version = "1.0.18"

View File

@ -17,6 +17,10 @@ tauri-plugin-single-instance = { version = "2.0.0", features = ["deep-link"] }
name = "drop_app_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build]
rustflags = ["-C", "target-feature=+aes,+sse2"]
[build-dependencies]
tauri-build = { version = "2.0.0", features = [] }
@ -41,7 +45,7 @@ tokio = { version = "1.40.0", features = ["rt", "tokio-macros"] }
versions = { version = "6.3.2", features = ["serde"] }
urlencoding = "2.1.3"
rustix = "0.38.37"
gxhash = "3.4.1"
gxhash = "2.3.0"
[dependencies.uuid]
version = "1.10.0"

View File

@ -2,7 +2,7 @@ use crate::auth::generate_authorization_header;
use crate::db::DatabaseImpls;
use crate::downloads::manifest::DropDownloadContext;
use crate::DB;
use gxhash::GxHasher;
use gxhash::{gxhash128, GxHasher};
use log::info;
use std::{fs::{File, OpenOptions}, hash::Hasher, io::{BufWriter, Seek, SeekFrom, Write}, path::PathBuf};
use urlencoding::encode;
@ -61,7 +61,7 @@ pub fn download_game_chunk(ctx: DropDownloadContext) {
.send()
.unwrap();
let mut file = FileWriter::new(ctx.path);
let mut file: FileWriter = FileWriter::new(ctx.path);
if ctx.offset != 0 {
file
@ -73,13 +73,18 @@ pub fn download_game_chunk(ctx: DropDownloadContext) {
// Writing directly to disk to avoid write spikes that delay everything
response.copy_to(&mut file).unwrap();
let data = response.bytes().unwrap();
let checksum = gxhash128(&*data.clone(), 0);
let res = file.write(&*data).unwrap();
//response.copy_to(&mut file).unwrap();
let res = hex::encode(file.finish().to_le_bytes());
if res == ctx.checksum {
info!("Matched Checksum {}", res);
}
else {
info!("Checksum failed {}", res);
info!("Checksum failed. Original: {}, Calculated: {}", ctx.checksum, res);
info!("Other Checksum: {}", hex::encode(checksum.to_le_bytes()));
}
// stream.flush().unwrap();