Skip to main content

ensure_file_exists_or_download_http_with_config

Function ensure_file_exists_or_download_http_with_config 

Source
pub fn ensure_file_exists_or_download_http_with_config(
    filepath: &Path,
    url: &str,
    checksums: Option<&Path>,
    timeout_secs: u64,
    retry_config: Option<RetryConfig>,
    initial_jitter_ms: Option<u64>,
) -> Result<()>
Expand description

Ensures that a file exists at the specified path by downloading it if necessary, with custom timeout, retry config, and initial jitter delay.

§Parameters

  • filepath: The path where the file should exist.
  • url: The URL to download from if the file doesn’t exist.
  • checksums: Optional path to checksums file for verification.
  • timeout_secs: Timeout in seconds for response headers and each body read.
  • retry_config: Optional custom retry configuration (uses sensible defaults if None).
  • initial_jitter_ms: Optional initial jitter delay in milliseconds before download (defaults to 100-600ms if None).

§Errors

Returns an error if:

  • The HTTP request cannot be sent or returns a non-success status code after retries.
  • Any I/O operation fails during file creation, reading, or writing.
  • Checksum verification or JSON parsing fails.