Add resumable downloads and exponential-backoff retries#1009
Open
chuckyutan wants to merge 2 commits into
Open
Add resumable downloads and exponential-backoff retries#1009chuckyutan wants to merge 2 commits into
chuckyutan wants to merge 2 commits into
Conversation
Large tracks would fail permanently on a single connection drop (IncompleteRead) because downloads were not resumable and only one retry was attempted. - fast_async_download: resume interrupted downloads via the Range header, appending only when the server honors it with 206 (falls back to a fresh download on 200 to avoid duplicating bytes; treats 416 as already-complete). Covers Qobuz, Tidal, SoundCloud-FLAC and unencrypted Deezer. - track.py: retry up to 3 times (4 attempts total) with exponential backoff (2s/4s/8s) instead of giving up after one retry. Applies to all sources. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Spin up a local HTTP server that interrupts the first response mid-stream (reproducing IncompleteRead) and verify that a retry resumes via the Range header and produces a byte-for-byte correct file. Also covers the 200-fallback case where the server ignores Range, ensuring the partial file is overwritten rather than appended to. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Problem
Large tracks fail permanently on a single connection drop. A
requests-levelIncompleteReadduring a long download bubbles up, and the current logic only retries once before giving up — and that retry restarts the download from byte 0. On flaky connections or large hi-res files, a single mid-stream drop is enough to lose the whole track.Example failure:
Changes
fast_async_download— resumable downloadsRange: bytes=N-header.ab) only when the server honors the range with206 Partial Content. If it responds200 OK(range ignored), fall back to a fresh overwrite (wb) so existing bytes aren't duplicated/corrupted.416 Range Not Satisfiableas already-complete and return.fast_async_download: Qobuz, Tidal, SoundCloud (FLAC), and unencrypted Deezer.track.py— more retries with backoffNotes