diff --git a/src/cmd/init/bootstrap.rs b/src/cmd/init/bootstrap.rs index 7c94f78..0a31864 100644 --- a/src/cmd/init/bootstrap.rs +++ b/src/cmd/init/bootstrap.rs @@ -143,13 +143,16 @@ 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 resp = reqwest::get(seed_url).await?; - fs::rename(tmp_file, output_file) - .await - .map_err(|e| format_err!("seed rename failed: {e}"))?; + 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(()) }