From 64ead0cb7db69b29c9a1a8db2a0b4a4e1e5bb2c7 Mon Sep 17 00:00:00 2001 From: gambitier Date: Thu, 6 Jun 2024 23:34:58 +0530 Subject: [PATCH] fix(juliaup): Error handling for `juliaup self update` (non-Windows) --- src/operations.rs | 46 +++++++++++++++++----------------------------- 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/src/operations.rs b/src/operations.rs index 8ff0e638..34518e78 100644 --- a/src/operations.rs +++ b/src/operations.rs @@ -1330,35 +1330,23 @@ fn download_direct_download_etags( ) -> Result> { 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) }