Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Fix callback signature #79

Merged
merged 1 commit into from
Aug 9, 2016
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public void run() {
File file = new File(RNFetchBlobFS.getTmpPath(RNFetchBlob.RCTContext, cacheKey) + ext);

if (file.exists()) {
callback.invoke(null, file.getAbsolutePath());
callback.invoke(null, null, file.getAbsolutePath());
return;
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/ios/RNFetchBlobNetwork.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ - (void) sendRequest:(__weak NSDictionary * _Nullable )options

// the session trust any SSL certification


NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
if([options valueForKey:@"timeout"] != nil)
{
Expand All @@ -153,7 +153,7 @@ - (void) sendRequest:(__weak NSDictionary * _Nullable )options

destPath = [RNFetchBlobFS getTempPath:cacheKey withExtension:[self.options valueForKey:CONFIG_FILE_EXT]];
if ([[NSFileManager defaultManager] fileExistsAtPath:destPath]) {
callback(@[[NSNull null], destPath]);
callback(@[[NSNull null], @[[NSNull null], destPath]);
return;
}
}
Expand Down Expand Up @@ -190,7 +190,7 @@ - (void) sendRequest:(__weak NSDictionary * _Nullable )options
- (void) URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveResponse:(NSURLResponse *)response completionHandler:(void (^)(NSURLSessionResponseDisposition))completionHandler
{
expectedBytes = [response expectedContentLength];

NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response;
NSInteger statusCode = [(NSHTTPURLResponse *)response statusCode];
if ([response respondsToSelector:@selector(allHeaderFields)])
Expand Down Expand Up @@ -229,7 +229,7 @@ - (void) URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dat
@"timeout" : @NO,
@"status": [NSString stringWithFormat:@"%d", statusCode ]
};

[self.bridge.eventDispatcher
sendDeviceEventWithName: EVENT_STATE_CHANGE
body:respInfo
Expand Down Expand Up @@ -272,7 +272,7 @@ - (void) URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dat
{
[writeStream write:[data bytes] maxLength:[data length]];
}

if([progressTable valueForKey:taskId] == @YES)
{
[self.bridge.eventDispatcher
Expand All @@ -296,15 +296,15 @@ - (void) URLSession:(NSURLSession *)session didBecomeInvalidWithError:(nullable

- (void) URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error
{

self.error = error;
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];

NSString * respType = [respInfo valueForKey:@"respType"];
if(error != nil) {
NSLog([error localizedDescription]);
}

if(respFile == YES)
{
[writeStream close];
Expand All @@ -321,7 +321,7 @@ - (void) URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCom
[respData base64EncodedStringWithOptions:0]
]);
}

[taskTable removeObjectForKey:taskId];
[uploadProgressTable removeObjectForKey:taskId];
[progressTable removeObjectForKey:taskId];
Expand Down