Skip to contents

A fixed timeout_s is either needlessly short for a large, genuinely-slow-but-healthy archive or needlessly long for a small one that has actually stalled – confirmed live (a real ~65MB OSF zip transferred at ~2.2MB/s before the underlying connection stalled entirely, so a fixed 120s timeout would have both accepted that same rate as fine for a small archive AND cut off a large, merely-slow one at the same wall-clock point). expected_bytes (the sum of the selected files' own sizes – the same estimate every zip-download call site already computes to decide whether the zip is worth taking over file-by-file) is scaled at a conservative floor of 200KB/s – slower than every real transfer observed so far (Zenodo, Dryad, OSF all measured well above 1MB/s when healthy) but fast enough not to fail a large, honestly slow connection.

Usage

.zip_timeout_for_size(
  timeout_s,
  expected_bytes = NA_real_,
  min_bytes_per_s = 200 * 1024
)

Arguments

timeout_s

the caller's own timeout, in seconds – a floor, never reduced: a small archive still gets at least this many seconds even when the size-derived value would be shorter

expected_bytes

the expected transfer size in bytes, or NA when unknown (in which case timeout_s is returned unchanged)

min_bytes_per_s

the conservative transfer-rate floor used to derive a timeout from expected_bytes

Value

the timeout to actually use, in seconds