feat(resume): Add ability to resume download where it left off #6
Open
br3akzero wants to merge 5 commits intops5-payload-dev:masterfrom
Open
feat(resume): Add ability to resume download where it left off #6br3akzero wants to merge 5 commits intops5-payload-dev:masterfrom
br3akzero wants to merge 5 commits intops5-payload-dev:masterfrom
Conversation
br3akzero
commented
Mar 25, 2026
- 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.
Author
|
@john-tornblom Just a naive implementation of resume functionality, nothing fancy. Still better than not |
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.
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.