Skip to content

Commit

Permalink
Merge pull request #88 from KisaragiEffective/wawa
Browse files Browse the repository at this point in the history
  • Loading branch information
KisaragiEffective authored Oct 14, 2024
2 parents 9d71fec + 6bd40a6 commit ca063ae
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ fn main() {
// Base64エンジンを作るのはゼロコストではないので使いまわす
let base64_engine = base64::engine::GeneralPurpose::new(&STANDARD, GeneralPurposeConfig::new());
// HTTPクライアントを作るのは少なくともゼロコストではないので使いまわす
assets.into_par_iter().for_each(|kv| process(kv, &args, &client, force, &sender, &base64_engine));
assets.into_par_iter().for_each(|kv| process(kv.1, &args, &client, force, &sender, &base64_engine));
// eprintln!("ended!!");
please_exit.send(()).expect("error send");
// eprintln!("signal sended, waiting join");
Expand All @@ -192,7 +192,7 @@ fn main() {
}

fn process<BE: base64::Engine>(
(_, meta): (String, AssetMappingValue),
meta: AssetMappingValue,
args: &Args,
client: &Client,
force: bool,
Expand All @@ -202,7 +202,7 @@ fn process<BE: base64::Engine>(
let size = meta.size;
let hash = &meta.hash;
{
sender.send(format!("{hash}: processing"));
sender.send(format!("{hash}: processing")).unwrap_or_default();
}

let (url, path) = create_channel(hash, &args.dot_minecraft);
Expand All @@ -226,7 +226,7 @@ fn process<BE: base64::Engine>(
};

if decoded_azure_md5_header == actual {
sender.send(format!("{hash}: cached; skipping"));
sender.send(format!("{hash}: cached; skipping")).unwrap_or_default();
break 'download
}
}
Expand All @@ -239,9 +239,9 @@ fn process<BE: base64::Engine>(
if args.unsafe_danger_skip_validation_hash_and_size {
sender.send(format!(
"{hash}: actual size or hash did not match, but it will be SAVED!! Please be aware that this feature is NOT SUPPORTED. USE AT YOUR OWN PERIL."
));
)).unwrap_or_default();
}
sender.send(format!("try: {:?}", &path));
sender.send(format!("try: {:?}", &path)).unwrap_or_default();
let f = match File::options().create(true).truncate(true).write(true).open(&path) {
Ok(f) => f,
Err(e) => panic!("failed to open {path:?}: {e:?}")
Expand All @@ -250,8 +250,8 @@ fn process<BE: base64::Engine>(
buf_writer.write_all(&bytes).expect("failed to write to file");
} else {
sender.send(
format!("{hash}: hash mismatch. actual hash is {actual_hash}; skipping")
);
format!("{hash}: hash mismatch. actual hash is {actual_hash}; skipping")
).unwrap_or_default();
}
}
}
Expand Down Expand Up @@ -287,8 +287,5 @@ fn create_channel(hash: &Sha1Hash, base_dir: &Path) -> (Url, PathBuf) {
}

fn sha1_hash(bytes: &[u8]) -> Sha1Hash {
let mut s = Sha1::new();
s.update(bytes);

Sha1Hash(s.digest())
Sha1Hash(Sha1::from(bytes).digest())
}

0 comments on commit ca063ae

Please sign in to comment.