Skip to content

feat(resume): Add ability to resume download where it left off #6

Open
br3akzero wants to merge 5 commits intops5-payload-dev:masterfrom
br3akzero:feat/resume
Open

feat(resume): Add ability to resume download where it left off #6
br3akzero wants to merge 5 commits intops5-payload-dev:masterfrom
br3akzero:feat/resume

Conversation

@br3akzero
Copy link
Copy Markdown

  • Add download resume support by skipping already-downloaded pieces and appending to existing files.
  • Fix speed/ETA calculation for resumed sessions.

Check for existing file on disk and skip already-downloaded pieces
based on file size. Open in append mode when resuming. Track
session-only bytes for accurate speed and ETA calculation.
@br3akzero
Copy link
Copy Markdown
Author

br3akzero commented Mar 25, 2026

@john-tornblom Just a naive implementation of resume functionality, nothing fancy. Still better than not
having it, especially for larger downloads. Let me know what you think.

When a download is interrupted mid-piece, the partial data remains in
the file. On resume, seek back and truncate to the last complete piece
boundary so the piece is re-downloaded cleanly.
Detect connection hangs via CURLOPT_LOW_SPEED_LIMIT (1000 bytes/sec for
30s). On failure, retry the piece from the last byte offset using HTTP
range requests, up to 20 attempts with 30s delay between each. The SHA
context stays alive across retries so hash verification remains valid.
@br3akzero
Copy link
Copy Markdown
Author

Also added in-session retry logic: detects stalled connections (below 1000 bytes/sec for 30s) and retries the failed piece up to 20 times with HTTP range resume, so downloads survive flaky connections without restarting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant