2 months ago
dc83f4fReported in #270: about an hour of downloading, ~30% of the model fetched, then "failed while streaming ONNX model download" and everything discarded. The transfer was a single GET streamed to a temp file, with the temp file deleted on any error and no retry. The per-read timeout is 120s, so one network stall on a slow link threw away every byte already fetched - and the next attempt started from zero. Retry up to five times, resuming with a Range request. The running hash keeps its state across attempts because no downloaded byte is discarded, so a resume costs a round trip rather than the megabytes already on disk. Two cases the naive version gets wrong, both covered by tests: - A body that ends short is what a dropped connection looks like to the reader. That is now a retry from the last byte, not a truncation error - it is the exact failure this exists for. - A server that ignores Range answers 200 with the whole body. Appending it would corrupt the file, so the transfer restarts instead.
Parent16ec9b3