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

Reject stopped download if resumable is not set #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1095,9 +1095,10 @@ function stopDownload(jobId: number): void;
```
**VERIFIED:** Android, iOS.

Aborts a file download job. The partial file will remain on the filesystem,
and the promise returned from the aborted [downloadFile()] call will reject
with an error.
Aborts a file download job. The partial file will remain on the filesystem.
If resume is not supported (Android), or if the `resumable` optional argument
is not set when calling [downloadFile()], the promise returned from the aborted
[downloadFile()] call will reject with an error.
- `jobId` — **number** — Download job ID (see [downloadFile()]).

### stopUpload()
Expand Down
6 changes: 2 additions & 4 deletions ios/Downloader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,9 @@ - (void)stopDownload
{
if (_task.state == NSURLSessionTaskStateRunning) {
[_task cancelByProducingResumeData:^(NSData * _Nullable resumeData) {
if (resumeData != nil) {
if (resumeData != nil && self->_params.resumableCallback) {
self.resumeData = resumeData;
if (self->_params.resumableCallback) {
self->_params.resumableCallback();
}
self->_params.resumableCallback();
} else {
NSError *error = [NSError errorWithDomain:@"RNFS"
code:0 //used to pass an NSString @"Aborted" here, but it needs an NSInteger
Expand Down