Download a file using curl with retry.
(url: &str, path: &std::path::Path)
| 338 | |
| 339 | /// Download a file using curl with retry. |
| 340 | fn download_with_curl(url: &str, path: &std::path::Path) -> Result<()> { |
| 341 | // Try curl first |
| 342 | let output = Command::new("curl") |
| 343 | .args([ |
| 344 | "-L", |
| 345 | "--fail", |
| 346 | "--retry", |
| 347 | "3", |
| 348 | "--retry-delay", |
| 349 | "2", |
| 350 | "-o", |
| 351 | &path.display().to_string(), |
| 352 | url, |
| 353 | ]) |
| 354 | .output()?; |
| 355 | |
| 356 | if output.status.success() && path.exists() { |
| 357 | return Ok(()); |
| 358 | } |
| 359 | |
| 360 | // Fallback: try wget |
| 361 | let output = Command::new("wget") |
| 362 | .args(["-O", &path.display().to_string(), url]) |
| 363 | .output()?; |
| 364 | |
| 365 | if output.status.success() && path.exists() { |
| 366 | return Ok(()); |
| 367 | } |
| 368 | |
| 369 | Err(anyhow!( |
| 370 | "Failed to download git from {}.\n\ |
| 371 | Please check your internet connection and try again.\n\ |
| 372 | Or download manually from https://git-scm.com", |
| 373 | url |
| 374 | )) |
| 375 | } |
| 376 | |
| 377 | /// Walk directory recursively (simple implementation). |
| 378 | fn walkdir(dir: &Path) -> Vec<std::path::PathBuf> { |
no test coverage detected