mach.io.utils.cached_download#
- mach.io.utils.cached_download(
- url: str,
- cache_dir: str | Path = PosixPath('/home/runner/.cache/mach'),
- filename: str | Path | None = None,
- timeout: int = 30,
- *,
- overwrite: bool = False,
- expected_size: int | None = None,
- expected_hash: str | None = None,
- digest: None | str | Callable[[], hashlib._Hash] = None,
- show_progress: bool = True,
- Download a file and cache it with optional integrity verification. - Parameters:
- url – URL to download 
- cache_dir – Directory to cache the file in 
- filename – Name to save the file as (default: derived from URL) if absolute path is provided, it will be used as-is without cache-dir 
- timeout – Connection timeout in seconds 
- overwrite – Whether to overwrite existing files 
- expected_hash – Expected hash value for integrity verification 
- digest – Hash algorithm to use (default: “sha1”) 
- expected_size – Expected file size in bytes 
- show_progress – Whether to show progress bar (requires tqdm) 
 
- Returns:
- Path to the cached file