Fix double completion callback in RCTJavascriptLoader

Reviewed By: foghina, mmmulani

Differential Revision: D3541511

fbshipit-source-id: 9a0a4be635ca910cb1a5c875a0f4a2b82c51cf71
This commit is contained in:
Pieter De Baets 2016-07-10 12:23:42 -07:00 committed by Facebook Github Bot 8
parent c0316c695d
commit 4aedcc7670
1 changed files with 9 additions and 10 deletions

View File

@ -60,7 +60,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
} }
magicNumber = NSSwapLittleIntToHost(magicNumber); magicNumber = NSSwapLittleIntToHost(magicNumber);
if (magicNumber == RCTRAMBundleMagicNumber) { if (magicNumber == RCTRAMBundleMagicNumber) {
NSData *source = [NSData dataWithBytes:&magicNumber length:sizeof(magicNumber)]; NSData *source = [NSData dataWithBytes:&magicNumber length:sizeof(magicNumber)];
NSError *error = nil; NSError *error = nil;
@ -73,16 +72,16 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
sourceLength = statInfo.st_size; sourceLength = statInfo.st_size;
} }
onComplete(error, source, sourceLength); onComplete(error, source, sourceLength);
} else {
// Reading in a large bundle can be slow. Dispatch to the background queue to do it.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSError *error = nil;
NSData *source = [NSData dataWithContentsOfFile:scriptURL.path
options:NSDataReadingMappedIfSafe
error:&error];
onComplete(error, source, source.length);
});
} }
// Reading in a large bundle can be slow. Dispatch to the background queue to do it.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSError *error = nil;
NSData *source = [NSData dataWithContentsOfFile:scriptURL.path
options:NSDataReadingMappedIfSafe
error:&error];
onComplete(error, source, source.length);
});
return; return;
} }