add .corrupt logic just like with the py version
This commit is contained in:
parent
bd118b3164
commit
6a6b453953
@ -225,8 +225,13 @@ fn main() {
|
||||
for i in 0..packets.len() {
|
||||
crc32.update(&packets[i]);
|
||||
if packet_hashes[i] != crc32.clone().finalize() {
|
||||
println!("Packet {} hash does not match", i);
|
||||
todo!("Request packets again")
|
||||
println!("Packet {} crc does not match, writing .corrupt", i);
|
||||
//TODO: Request packets again
|
||||
let mut file = std::fs::File::create("received/".to_string()+filename+".corrupt").expect("Failed to create file");
|
||||
for i in 0..packets.len() {
|
||||
file.write_all(&packets[i]).expect("Failed to write to file");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,7 +244,12 @@ fn main() {
|
||||
let client_hash = hasher.finalize();
|
||||
|
||||
if client_hash[..64] != server_hash {
|
||||
panic!("Hashes do not match, correct hash: {:?}, client hash: {:?}", server_hash, client_hash);
|
||||
println!("Hashes do not match, correct hash: {:?}, client hash: {:?}", server_hash, client_hash);
|
||||
let mut file = std::fs::File::create("received/".to_string()+filename+".corrupt").expect("Failed to create file");
|
||||
for i in 0..packets.len() {
|
||||
file.write_all(&packets[i]).expect("Failed to write to file");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user