-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: Empty last chunk case in resumable upload that is not a stream #1802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1062,10 +1062,14 @@ def next_chunk(self, http=None, num_retries=0): | |||||||||
| "Content-Length": str(chunk_end - self.resumable_progress + 1), | ||||||||||
| } | ||||||||||
|
|
||||||||||
| # An empty file results in chunk_end = -1 and size = 0 | ||||||||||
| # sending "bytes 0--1/0" results in an invalid request | ||||||||||
| # Only add header "Content-Range" if chunk_end != -1 | ||||||||||
| if chunk_end != -1: | ||||||||||
| if chunk_end - self.resumable_progress + 1 == 0 and chunk_end != -1: | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest assigning before the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure I am tracking here on two things. One: Do you mean for this to equate to a boolean?This line from your example: yields And yet Two: Can you simply suggest the code edit you want to see using GitHub's suggestion tool?I am not tracking exactly what you want in terms of placement and modifications of the new code. Are you suggesting the following? This seems like doesn't do what we want (especially if
Suggested change
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agrees with @chalmerlowe and from my understanding of this change, I believe it might be hard to simplify the logic here. I propose we merge this as is, if there are further logic simplifications possible, I suggest we resolve through further PRs. Note that this commit is authored while I'm still employed at Google so merging it as is would have much lesser copyright related hoops to jump through. |
||||||||||
| # This is the last chunk, it's empty but the file is not empty. | ||||||||||
| # Send a Content-Range that ends this file. | ||||||||||
| headers["Content-Range"] = "bytes */%s" % (size,) | ||||||||||
| elif chunk_end != -1: | ||||||||||
| # An empty file results in chunk_end = -1 and size = 0 | ||||||||||
| # sending "bytes 0--1/0" results in an invalid request | ||||||||||
| # Only add header "Content-Range" if chunk_end != -1 | ||||||||||
| headers["Content-Range"] = "bytes %d-%d/%s" % ( | ||||||||||
| self.resumable_progress, | ||||||||||
| chunk_end, | ||||||||||
|
|
||||||||||
Uh oh!
There was an error while loading. Please reload this page.