-
Notifications
You must be signed in to change notification settings - Fork 878
chore: Error handling when upload id I'd incorrect for Resumable upload #24234
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 4 commits
30c1128
b7de7d2
392b0ee
6d8bd82
5eda287
b5c1d10
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 |
|---|---|---|
|
|
@@ -149,7 +149,7 @@ def initiate_resumable_upload(client) | |
| # Reinitiating resumable upload | ||
| def reinitiate_resumable_upload(client) | ||
| logger.debug { sprintf('Restarting resumable upload command to %s', url) } | ||
| check_resumable_upload client | ||
| return false unless check_resumable_upload client | ||
| upload_io.pos = @offset | ||
| end | ||
|
|
||
|
|
@@ -224,6 +224,10 @@ def check_resumable_upload(client) | |
| # Initiating call | ||
| response = client.put(@upload_url, "", request_header) | ||
| handle_resumable_upload_http_response_codes(response) | ||
| if response.status.to_i == 404 | ||
| logger.debug { sprintf("Failed to fetch upload session. Response: #{response.status.to_i} - #{response.body}") } | ||
| false | ||
| end | ||
|
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. Return true here? 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. The call to check the upload ID's status failed with a 404 error. That status code means the upload ID is not recognized by the server, so the process is stopping and returning false. 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. Got it thanks |
||
| end | ||
|
|
||
| # Cancel resumable upload | ||
|
|
@@ -235,13 +239,13 @@ def cancel_resumable_upload(client) | |
| response = client.delete(@upload_url, nil, request_header) | ||
| handle_resumable_upload_http_response_codes(response) | ||
|
|
||
| if !@upload_incomplete && (400..499).include?(response.status.to_i) | ||
| if !@upload_incomplete && (400..499).include?(response.status.to_i) && response.status.to_i != 404 | ||
shubhangi-google marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| @close_io_on_finish = true | ||
| true # method returns true if upload is successfully cancelled | ||
| else | ||
| logger.debug { sprintf("Failed to cancel upload session. Response: #{response.status.to_i} - #{response.body}") } | ||
shubhangi-google marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| false | ||
| end | ||
|
|
||
| end | ||
|
|
||
| def handle_resumable_upload_http_response_codes(response) | ||
|
|
||
|
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. Could you also add tests for success cases. 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. success test cases were added and have been merged already here |
Uh oh!
There was an error while loading. Please reload this page.