Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit fcc05c6

Browse files
committed
Binary hash ios
1 parent 65b906d commit fcc05c6

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

ios/CodePush/CodePushUpdateUtils.m

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ + (void)addContentsOfFolderToManifest:(NSString *)folderPath
4040
}
4141
}
4242

43+
+ (void)addFileToManifest:(NSURL *)fileURL
44+
manifest:(NSMutableArray *)manifest
45+
{
46+
if ([[NSFileManager defaultManager] fileExistsAtPath:[fileURL path]]) {
47+
NSData *fileContents = [NSData dataWithContentsOfURL:fileURL];
48+
NSString *fileContentsHash = [self computeHashForData:fileContents];
49+
[manifest addObject:[NSString stringWithFormat:@"%@/%@:%@", [self manifestFolderPrefix], [fileURL lastPathComponent], fileContentsHash]];
50+
}
51+
}
52+
4353
+ (NSString *)computeFinalHashFromManifest:(NSMutableArray *)manifest
4454
error:(NSError **)error
4555
{
@@ -190,9 +200,9 @@ + (NSString *)getHashForBinaryContents:(NSURL *)binaryBundleUrl
190200
}
191201
}
192202

193-
NSData *jsBundleContents = [NSData dataWithContentsOfURL:binaryBundleUrl];
194-
NSString *jsBundleContentsHash = [self computeHashForData:jsBundleContents];
195-
[manifest addObject:[[NSString stringWithFormat:@"%@/%@:", [self manifestFolderPrefix], [binaryBundleUrl lastPathComponent]] stringByAppendingString:jsBundleContentsHash]];
203+
[self addFileToManifest:binaryBundleUrl manifest:manifest];
204+
[self addFileToManifest:[binaryBundleUrl URLByAppendingPathExtension:@"meta"] manifest:manifest];
205+
196206
binaryHash = [self computeFinalHashFromManifest:manifest error:error];
197207

198208
// Cache the hash in user preferences. This assumes that the modified date for the

0 commit comments

Comments
 (0)