Skip to content

Commit

Permalink
always pass key parameter to RCTReadFile
Browse files Browse the repository at this point in the history
Differential Revision: D5921064

fbshipit-source-id: ad2dd352060fcb2c873dc5a91781797c9abd6c33
  • Loading branch information
Corey-Peyton committed Sep 28, 2017
1 parent 7850aa9 commit f43d44a
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions RCTAsyncLocalStorage.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f43d44a

Please sign in to comment.