Permalink
Browse files

always pass key parameter to RCTReadFile

Differential Revision: D5921064

fbshipit-source-id: ad2dd352060fcb2c873dc5a91781797c9abd6c33
  • Loading branch information...
fromcelticpark authored and facebook-github-bot committed Sep 28, 2017
1 parent 652dfd0 commit c4f7ce9afdea41fb64b6246894840873bf524d98
Showing with 12 additions and 6 deletions.
  1. +12 −6 React/Modules/RCTAsyncLocalStorage.m
@@ -51,14 +51,20 @@ static void RCTAppendError(NSDictionary *error, NSMutableArray<NSDictionary *> *
NSError *error;
NSStringEncoding encoding;
NSString *entryString = [NSString stringWithContentsOfFile:filePath usedEncoding:&encoding error:&error];
NSDictionary *extraData = @{@"key": RCTNullIfNil(key)};
if (error) {
*errorOut = RCTMakeError(@"Failed to read storage file.", error, @{@"key": key});
} else if (encoding != NSUTF8StringEncoding) {
*errorOut = RCTMakeError(@"Incorrect encoding of storage file: ", @(encoding), @{@"key": key});
} else {
return entryString;
if (errorOut) *errorOut = RCTMakeError(@"Failed to read storage file.", error, extraData);
return nil;
}
if (encoding != NSUTF8StringEncoding) {
if (errorOut) *errorOut = RCTMakeError(@"Incorrect encoding of storage file: ", @(encoding), extraData);
return nil;
}
return entryString;
}
return nil;
}
@@ -235,7 +241,7 @@ - (NSDictionary *)_ensureSetup
}
if (!_haveSetup) {
NSDictionary *errorOut;
NSString *serialized = RCTReadFile(RCTGetManifestFilePath(), nil, &errorOut);
NSString *serialized = RCTReadFile(RCTGetManifestFilePath(), RCTManifestFileName, &errorOut);
_manifest = serialized ? RCTJSONParseMutable(serialized, &error) : [NSMutableDictionary new];
if (error) {
RCTLogWarn(@"Failed to parse manifest - creating new one.\n\n%@", error);

0 comments on commit c4f7ce9

Please sign in to comment.