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

fix(juliaup): handle timeout error to prevent crash on Result::unwrap() #951

Merged
merged 5 commits into from
Jul 5, 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
46 changes: 17 additions & 29 deletions src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1330,35 +1330,23 @@ fn download_direct_download_etags(
) -> Result<Vec<(String, String)>> {
let client = reqwest::blocking::Client::new();

let requests: Vec<_> = config_data
.installed_channels
.iter()
.filter_map(|(channel_name, channel)| {
if let JuliaupConfigChannel::DirectDownloadChannel {
path: _,
url,
local_etag: _,
server_etag: _,
version: _,
} = channel
{
let etag = client
.head(url)
.send()
.unwrap()
.headers()
.get("etag")
.unwrap()
.to_str()
.unwrap()
.to_string();

Some((channel_name.clone(), etag))
} else {
None
}
})
.collect();
let mut requests = Vec::new();

for (channel_name, channel) in &config_data.installed_channels {
if let JuliaupConfigChannel::DirectDownloadChannel { url, .. } = channel {
let etag = client
.head(url)
.send()?
.headers()
.get("etag")
.ok_or_else(|| anyhow!("ETag header not found in response"))?
.to_str()
.map_err(|e| anyhow!("Failed to parse ETag header: {}", e))?
.to_string();

requests.push((channel_name.clone(), etag));
}
}

Ok(requests)
}