Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: fix all warnings #88

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())
}