Skip to content
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

fix: on iOS, check http status when downloaded finished #635

Conversation

jackleemeta
Copy link
Contributor

@jackleemeta jackleemeta commented May 2, 2022

Problem:

I observed that when downloading an invalid resource, it returns a success in [URLSession: downloadTask: didFinishDownloadingToURL:], then it returns a failure in [URLSession: task: didCompleteWithError:], finally callback twice. The expectation should be to only return a failure.

Why:

  1. In [URLSession: downloadTask: didFinishDownloadingToURL:] , the http status code of the invalid resource's downloadTask is 404 or other failed code, and the location exists invalid temporary file which will be copied to the destinationURL. The copy result is succeeded, so it returns a success.

  2. In [URLSession: task: didCompleteWithError:], invalid resource task status code is also 404 or other failed code, so it returns a failure.

Solution:

When 404 or other failed http status code appears, ignore it in [URLSession: downloadTask: didFinishDownloadingToURL:], but process it in [URLSession: task: didCompleteWithError:], ensure to only return a failure.

@hnvn
Copy link
Member

hnvn commented May 15, 2022

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants