Learn R Programming

reproducible (version 3.2.1)

.useParallelDownload: Decide whether to use the parallel ranged download path

Description

Internal policy helper for Feature A, separated from the download mechanism so it can be unit-tested without network access. The parallel path is gated on the opt-in reproducible.urlRemap being set: if no remap function is set, it is never used, regardless of reproducible.parallel.streams. When a remap is set, the path is used only when reproducible.parallel.streams > 1 (the default is 48L; set it to 1L to disable), the curl and httr2 packages are available, the server advertises Accept-Ranges: bytes, and the file is larger than reproducible.parallel.threshold. When that gate is not met, the (potentially network-touching) .probeRange() call is skipped entirely.

Usage

.useParallelDownload(
  url,
  streams = .parallelDownload(),
  threshold = getOption("reproducible.parallel.threshold", 10 * 1024^2),
  verbose = getOption("reproducible.verbose", 1)
)

Value

A list with use (logical) and info (the .probeRange() result, or NULL when the probe was skipped).

Arguments

url

The resolved URL.

streams

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

threshold

Size threshold in bytes.

verbose

Numeric verbosity level.