Skip to content

Conversation

@aniastrzezek
Copy link
Contributor

This PR fixes error not being thrown when download finishes with error due to eg. lost network connection.

@Thomas101
Copy link
Contributor

This works a treat! I noticed that the commits come from a fork that's some 70 or so commits behind master, so I patched master locally (065acc4) and it worked perfectly from there.

To test, start downloading file - place in aeroplane mode, the file download hangs indefinitely (no promise rejection or resolution). With the fix the promise rejects shortly after being placed offline

@Thomas101
Copy link
Contributor

Just noticed that if you cancel the download task this throws an error as the promise rejection gets called twice in 2.0.1-rc.2. The following fixes that behaviour

- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error
{
  if (error && error.code != -999) {
    _params.errorCallback(error);
  }
}

Happy to open a new PR for this if it helps, we have a fork over at https://github.com/locly/react-native-fs

@aniastrzezek
Copy link
Contributor Author

@Thomas101 Thanks for your comments!

Fork is based on the last released version (1.5.1). I'll take a look on task canceling issue!

@cjdell cjdell merged commit e212728 into itinance:master Jan 14, 2017
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.

3 participants