Skip to content

Commit

Permalink
[#31] iOS: downloadFile() - fix: progress callback should be called n…
Browse files Browse the repository at this point in the history
…o matter whether there is begin callback set or not
  • Loading branch information
birdofpreyru committed Mar 26, 2024
1 parent 1e75477 commit 7409907
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ios/Downloader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ - (NSString *)downloadFile:(RNFSDownloadParams*)params
- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite
{
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)downloadTask.response;
if (_params.beginCallback && !_statusCode) {

if (!_statusCode) {
_statusCode = [NSNumber numberWithLong:httpResponse.statusCode];
_contentLength = [NSNumber numberWithLong:httpResponse.expectedContentLength];
return _params.beginCallback(_statusCode, _contentLength, httpResponse.allHeaderFields);

if (_params.beginCallback) {
return _params.beginCallback(_statusCode, _contentLength, httpResponse.allHeaderFields);
}
}

if (_params.progressCallback && [_statusCode isEqualToNumber:[NSNumber numberWithInt:200]]) {
Expand Down

0 comments on commit 7409907

Please sign in to comment.