Repository navigation
Conversation
GetRange used end_byte both for the end of the requested range and for the end of each chunk request, so after the first request the range end was replaced by the chunk end and the loop stopped. Ranges larger than chunksize were silently truncated to one chunk (two when the total size was unknown). Keep the per-request end in its own variable.
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.
Download.GetRangeusedend_byteboth for the last byte of the requested range and for the last byte of each chunk request. After the first__ComputeEndBytecall the range end was replaced by the chunk end, so theprogress <= end_byteloop condition became false and the method returned after one chunk (two chunks when the total size was not known in advance). The result was a silently truncated stream whenever the range was larger thanchunksize; with the default 1 MiB chunksize this affects any range over 1 MiB.This change keeps the per-request end in a separate
chunk_endvariable, so the loop keeps going until the whole inclusive range has been fetched, as the docstring describes. Each request still uses a range of at mostchunksizebytes, anduse_chunks=Falsebehaves as before.The new
testGetRangeChunkedtest downloads ranges larger thanchunksizethrough a fake HTTP layer that honours theRangeheader (RFC 7233), with the total size known and unknown and with a negative start. It checks both the bytes written to the stream and the exactRangeheaders sent. It fails on master (only the first one or two chunks are requested) and passes with this change. All tests inapitools/base/pypass (227 on master, 228 with this change).This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.