mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2026-11-13 06:00:47 +08:00
`SeekableStream.generateReader` previously opened the upstream stream only once. If the connection closed before all bytes were read, caching failed with `unexpected EOF` and aborted the operation. Add `NewResumableReader` to reopen full-stream reads from the current byte offset after a read or resume-request error. Retries use linear backoff of 200 ms per attempt and are capped at five per read; an initial open error is returned directly. For known positive sizes, the reader stops at the declared length so a trailing upstream error after all bytes arrive does not fail the operation. Unknown or non-positive sizes retain the original unbounded behavior. Use the resumable reader for seekable stream caching, offline transfer uploads, and torrent generation. Resumption requires Range support, an accurate declared size, and unchanged content during the read. Add tests covering truncated HTTP responses, retry limits, and size boundaries.