From f892178d5dd863b8ca12ea721d339551b7833375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Cluseau?= Date: Mon, 21 Jul 2025 17:39:22 +0200 Subject: [PATCH] wget -> reqwest, now we can have openssl :) --- src/cmd/init/bootstrap.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/cmd/init/bootstrap.rs b/src/cmd/init/bootstrap.rs index 7c94f78..b4821a7 100644 --- a/src/cmd/init/bootstrap.rs +++ b/src/cmd/init/bootstrap.rs @@ -143,13 +143,23 @@ async fn seed_config( } async fn fetch_bootstrap(seed_url: &str, output_file: &str) -> Result<()> { - let tmp_file = &format!("{output_file}.new"); - let _ = fs::remove_file(tmp_file).await; - try_exec("wget", &["-O", tmp_file, seed_url]).await?; + let seed_url: reqwest::Url = seed_url.parse()?; - fs::rename(tmp_file, output_file) - .await - .map_err(|e| format_err!("seed rename failed: {e}"))?; + info!( + "fetching {output_file} from {}", + seed_url.host_str().unwrap_or("") + ); + + let resp = reqwest::get(seed_url).await?; + + if !resp.status().is_success() { + return Err(format_err!("HTTP request failed: {}", resp.status())); + } + + let data = (resp.bytes().await).map_err(|e| format_err!("HTTP download failed: {e}"))?; + + (fs::write(output_file, &data).await) + .map_err(|e| format_err!("output file write failed: {e}"))?; Ok(()) }