Skip to content
This repository has been archived by the owner on Feb 27, 2022. It is now read-only.

fix: Move iOS session init at download start into the synchronised block to avoid using invalidated session #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion ios/RNBackgroundDownloader.m
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ + (void)setCompletionHandlerWithIdentifier: (NSString *)identifier completionHan
NSLog(@"[RNBackgroundDownloader] - [Error] id, url and destination must be set");
return;
}
[self lazyInitSession];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url]];
if (headers != nil) {
Expand All @@ -126,6 +125,7 @@ + (void)setCompletionHandlerWithIdentifier: (NSString *)identifier completionHan
}

@synchronized (sharedLock) {
[self lazyInitSession];
NSURLSessionDownloadTask __strong *task = [urlSession downloadTaskWithRequest:request];
RNBGDTaskConfig *taskConfig = [[RNBGDTaskConfig alloc] initWithDictionary: @{@"id": identifier, @"destination": destination}];

Expand Down