Skip to content

Commit

Permalink
Hopefully fix some downloads would randomly fail?
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew121410 committed Sep 19, 2023
1 parent 1fd008d commit 94c118e
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/controllers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,29 @@ pub async fn download_jar_to_temp_dir(link: &String) -> DownloadedJar {
header::USER_AGENT,
"rust-reqwest/limonium".parse().unwrap(),
);
headers.insert(
header::ACCEPT,
"application/octet-stream".parse().unwrap(),
);
let response = reqwest::Client::new()

// This seems to break some downloads?
// headers.insert(
// header::ACCEPT,
// "application/octet-stream".parse().unwrap(),
// );

let response = reqwest::Client::builder()
.redirect(reqwest::redirect::Policy::limited(10))
.build()
.unwrap()
.get(link)
.headers(headers)
.send().await.unwrap();
.send()
.await
.unwrap();

// If the response is not successful, we should alert not exit though
if !response.status().is_success() {
println!("{} {}", "Failed to download file from".red(), link);
println!("{} {}", "Status code:".red(), response.status());
println!("{} {}", "Status text:".red(), response.status().canonical_reason().unwrap());
}

let path = temp_dir().join(&tmp_jar_name);
let mut file = File::create(path).unwrap();
Expand Down

1 comment on commit 94c118e

@andrew121410
Copy link
Owner Author

@andrew121410 andrew121410 commented on 94c118e Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue has been in Limonium since the beginning (hopefully this fixes it)

The issue only seems to happen when downloading waterfall or geyser not paper or floodgate though?
And it only happens at random times -> It's a intermittent issue

Please sign in to comment.