Learn R Programming

reproducible (version 3.2.1)

.parallelRangedDownload: Download a file in parallel using HTTP Range requests

Description

Internal helper for the opt-in parallel download path (Feature A). Splits [0, size) into n contiguous byte ranges and fetches them concurrently with one curl handle per part (each carrying its own Range: header) via curl's multi interface. On success the parts are concatenated in order and the total size is verified to equal size, so the result is byte-identical to a single-stream download. Returns FALSE (rather than erroring) on any partial failure or size mismatch, so the caller can fall back to single-stream.

Usage

.parallelRangedDownload(
  url,
  destFile,
  size,
  n,
  verbose = getOption("reproducible.verbose", 1)
)

Value

TRUE on verified success, otherwise FALSE.

Arguments

url

The (already-resolved, range-capable) URL.

destFile

The destination file path to assemble into.

size

Total expected size in bytes (from .probeRange()).

n

Number of parallel streams (reproducible.parallel.streams).

verbose

Numeric verbosity level.