mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-10 23:59:42 +08:00
verifyHashForZipUpdate -> verifyHashForDiffUpdate
This commit is contained in:
@@ -230,7 +230,8 @@ public class CodePushPackage {
|
||||
// Merge contents with current update based on the manifest
|
||||
String diffManifestFilePath = CodePushUtils.appendPathComponent(unzippedFolderPath,
|
||||
DIFF_MANIFEST_FILE_NAME);
|
||||
if (FileUtils.fileAtPathExists(diffManifestFilePath)) {
|
||||
boolean isDiffUpdate = FileUtils.fileAtPathExists(diffManifestFilePath);
|
||||
if (isDiffUpdate) {
|
||||
String currentPackageFolderPath = getCurrentPackageFolderPath();
|
||||
CodePushUpdateUtils.copyNecessaryFilesFromCurrentPackage(diffManifestFilePath, currentPackageFolderPath, newUpdateFolderPath);
|
||||
File diffManifestFile = new File(diffManifestFilePath);
|
||||
@@ -252,7 +253,9 @@ public class CodePushPackage {
|
||||
metadataFileFromOldUpdate.delete();
|
||||
}
|
||||
|
||||
CodePushUpdateUtils.verifyHashForZipUpdate(newUpdateFolderPath, newUpdateHash);
|
||||
if (isDiffUpdate) {
|
||||
CodePushUpdateUtils.verifyHashForDiffUpdate(newUpdateFolderPath, newUpdateHash);
|
||||
}
|
||||
|
||||
JSONObject updatePackageJSON = CodePushUtils.convertReadableToJsonObject(updatePackage);
|
||||
try {
|
||||
|
||||
@@ -31,7 +31,6 @@ public class CodePushUpdateUtils {
|
||||
addContentsOfFolderToManifest(fullFilePath, relativePath, manifest);
|
||||
} else {
|
||||
try {
|
||||
// Substring 1 because appendPathComponent creates a "/" prefix to the relativePath.
|
||||
manifest.add(relativePath + ":" + computeHash(new FileInputStream(file)));
|
||||
} catch (FileNotFoundException e) {
|
||||
// Should not happen.
|
||||
@@ -103,7 +102,7 @@ public class CodePushUpdateUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void verifyHashForZipUpdate(String folderPath, String expectedHash) {
|
||||
public static void verifyHashForDiffUpdate(String folderPath, String expectedHash) {
|
||||
ArrayList<String> updateContentsManifest = new ArrayList<String>();
|
||||
addContentsOfFolderToManifest(folderPath, "", updateContentsManifest);
|
||||
Collections.sort(updateContentsManifest);
|
||||
|
||||
@@ -111,9 +111,9 @@ failCallback:(void (^)(NSError *err))failCallback;
|
||||
error:(NSError **)error;
|
||||
+ (NSString *)findMainBundleInFolder:(NSString *)folderPath
|
||||
error:(NSError **)error;
|
||||
+ (BOOL)verifyHashForZipUpdate:(NSString *)finalUpdateFolder
|
||||
expectedHash:(NSString *)expectedHash
|
||||
error:(NSError **)error;
|
||||
+ (BOOL)verifyHashForDiffUpdate:(NSString *)finalUpdateFolder
|
||||
expectedHash:(NSString *)expectedHash
|
||||
error:(NSError **)error;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -257,8 +257,9 @@ NSString * const UnzippedFolderName = @"unzipped";
|
||||
}
|
||||
|
||||
NSString *diffManifestFilePath = [unzippedFolderPath stringByAppendingPathComponent:DiffManifestFileName];
|
||||
BOOL isDiffUpdate = [[NSFileManager defaultManager] fileExistsAtPath:diffManifestFilePath];
|
||||
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:diffManifestFilePath]) {
|
||||
if (isDiffUpdate) {
|
||||
// Copy the current package to the new package.
|
||||
NSString *currentPackageFolderPath = [self getCurrentPackageFolderPath:&error];
|
||||
if (error) {
|
||||
@@ -368,9 +369,9 @@ NSString * const UnzippedFolderName = @"unzipped";
|
||||
}
|
||||
}
|
||||
|
||||
if (![CodePushUpdateUtils verifyHashForZipUpdate:newUpdateFolderPath
|
||||
expectedHash:newUpdateHash
|
||||
error:&error]) {
|
||||
if (isDiffUpdate && ![CodePushUpdateUtils verifyHashForDiffUpdate:newUpdateFolderPath
|
||||
expectedHash:newUpdateHash
|
||||
error:&error]) {
|
||||
if (error) {
|
||||
failCallback(error);
|
||||
return;
|
||||
|
||||
@@ -127,9 +127,9 @@
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (BOOL)verifyHashForZipUpdate:(NSString *)finalUpdateFolder
|
||||
expectedHash:(NSString *)expectedHash
|
||||
error:(NSError **)error
|
||||
+ (BOOL)verifyHashForDiffUpdate:(NSString *)finalUpdateFolder
|
||||
expectedHash:(NSString *)expectedHash
|
||||
error:(NSError **)error
|
||||
{
|
||||
NSMutableArray *updateContentsManifest = [NSMutableArray array];
|
||||
[self addContentsOfFolderToManifest:finalUpdateFolder
|
||||
|
||||
Reference in New Issue
Block a user