MCPcopy Index your code
hub / github.com/AI45Lab/Code / download_with_curl

Function download_with_curl

core/src/git.rs:340–375  ·  view source on GitHub ↗

Download a file using curl with retry.

(url: &str, path: &std::path::Path)

Source from the content-addressed store, hash-verified

338
339/// Download a file using curl with retry.
340fn 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).
378fn walkdir(dir: &Path) -> Vec<std::path::PathBuf> {

Callers 3

install_git_macosFunction · 0.85
install_git_linuxFunction · 0.85
install_git_windowsFunction · 0.85

Calls 2

successMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected