lint
This commit is contained in:
parent
872bad1b25
commit
4a488abb8e
28
src/main.rs
28
src/main.rs
@ -41,13 +41,18 @@ fn download_and_launch(url: &str, file_path: &PathBuf, hash: Option<String>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clippy will suggest using if let or match, but i prefer it being somewhat readable
|
||||||
|
#[allow(clippy::unnecessary_unwrap)]
|
||||||
if file_path.exists() && hash.is_some() {
|
if file_path.exists() && hash.is_some() {
|
||||||
let sha1_local = file_get_sha1(file_path).to_lowercase();
|
let sha1_local = file_get_sha1(file_path).to_lowercase();
|
||||||
let sha1_remote = hash.unwrap().to_lowercase();
|
let sha1_remote = hash.unwrap().to_lowercase();
|
||||||
if sha1_local != sha1_remote {
|
if sha1_local != sha1_remote {
|
||||||
println!("Local hash: {}", sha1_local);
|
println!(
|
||||||
println!("Remote hash: {}", sha1_remote);
|
"Updating {}...\nLocal hash: {}\nRemote hash: {}",
|
||||||
println!("Updating {}...", file_path.display());
|
file_path.display(),
|
||||||
|
sha1_local,
|
||||||
|
sha1_remote
|
||||||
|
);
|
||||||
http::download_file(url, file_path);
|
http::download_file(url, file_path);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -65,7 +70,12 @@ fn download_and_launch(url: &str, file_path: &PathBuf, hash: Option<String>) {
|
|||||||
|
|
||||||
fn get_hash(game: &Game) -> Option<String> {
|
fn get_hash(game: &Game) -> Option<String> {
|
||||||
let cdn_info: Vec<CdnFile> = serde_json::from_str(&http::get_body_string(
|
let cdn_info: Vec<CdnFile> = serde_json::from_str(&http::get_body_string(
|
||||||
format!("{}/files.json?{}", MASTER, rand::Rng::gen_range(&mut rand::thread_rng(), 0..1000)).as_str(),
|
format!(
|
||||||
|
"{}/files.json?{}",
|
||||||
|
MASTER,
|
||||||
|
rand::Rng::gen_range(&mut rand::thread_rng(), 0..1000)
|
||||||
|
)
|
||||||
|
.as_str(),
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@ -97,9 +107,15 @@ fn main() {
|
|||||||
for g in GAMES.iter() {
|
for g in GAMES.iter() {
|
||||||
if g.client == game {
|
if g.client == game {
|
||||||
download_and_launch(
|
download_and_launch(
|
||||||
&format!("{}/{}/{}.exe?{}", MASTER, g.engine, g.client, rand::Rng::gen_range(&mut rand::thread_rng(), 0..1000)),
|
&format!(
|
||||||
|
"{}/{}/{}.exe?{}",
|
||||||
|
MASTER,
|
||||||
|
g.engine,
|
||||||
|
g.client,
|
||||||
|
rand::Rng::gen_range(&mut rand::thread_rng(), 0..1000)
|
||||||
|
),
|
||||||
&PathBuf::from(format!("{}.exe", g.client)),
|
&PathBuf::from(format!("{}.exe", g.client)),
|
||||||
get_hash(g)
|
get_hash(g),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user