isRunningBinary

This commit is contained in:
Geoffrey Goh
2016-01-20 17:45:54 -08:00
parent d20e9ccc1e
commit 88b7fb3af8
2 changed files with 12 additions and 7 deletions

View File

@@ -14,6 +14,7 @@
RCT_EXPORT_MODULE()
static BOOL didRollback = NO;
static BOOL isRunningBinaryVersion = NO;
static BOOL testConfigurationFlag = NO;
// These constants represent valid deployment statuses
@@ -62,6 +63,7 @@ static NSString *const PackageIsPendingKey = @"isPending";
if (error || !packageFile) {
NSLog(logMessageFormat, binaryJsBundleUrl);
isRunningBinaryVersion = YES;
return binaryJsBundleUrl;
}
@@ -73,6 +75,7 @@ static NSString *const PackageIsPendingKey = @"isPending";
NSDictionary *currentPackageMetadata = [CodePushPackage getCurrentPackage:&error];
if (error || !currentPackageMetadata) {
NSLog(logMessageFormat, binaryJsBundleUrl);
isRunningBinaryVersion = YES;
return binaryJsBundleUrl;
}
@@ -82,6 +85,7 @@ static NSString *const PackageIsPendingKey = @"isPending";
// Return package file because it is newer than the app store binary's JS bundle
NSURL *packageUrl = [[NSURL alloc] initFileURLWithPath:packageFile];
NSLog(logMessageFormat, packageUrl);
isRunningBinaryVersion = NO;
return packageUrl;
} else {
#ifndef DEBUG
@@ -89,6 +93,7 @@ static NSString *const PackageIsPendingKey = @"isPending";
#endif
NSLog(logMessageFormat, binaryJsBundleUrl);
isRunningBinaryVersion = YES;
return binaryJsBundleUrl;
}
}
@@ -557,9 +562,7 @@ RCT_EXPORT_METHOD(getNewStatusReport:(RCTPromiseResolveBlock)resolve
}
}
} else {
NSError *error;
NSString *currentPackageHash = [CodePushPackage getCurrentPackageHash:&error];
if (error || currentPackageHash == nil) {
if (isRunningBinaryVersion) {
// Check if the current appVersion has been reported. Use date as the binary identifier to
// handle binary releases that do not modify the appVersion.
NSURL *binaryJsBundleUrl = [CodePush bundleURL];

View File

@@ -40,8 +40,9 @@ import java.util.zip.ZipFile;
public class CodePush {
private static boolean testConfigurationFlag = false;
private static boolean didRollback = false;
private static boolean isRunningBinaryVersion = false;
private static boolean testConfigurationFlag = false;
private boolean didUpdate = false;
@@ -143,6 +144,7 @@ public class CodePush {
if (packageFilePath == null) {
// There has not been any downloaded updates.
CodePushUtils.logBundleUrl(binaryJsBundleUrl);
isRunningBinaryVersion = true;
return binaryJsBundleUrl;
}
@@ -158,6 +160,7 @@ public class CodePush {
binaryModifiedDateDuringPackageInstall == binaryResourcesModifiedTime &&
(this.isUsingTestConfiguration() || this.appVersion.equals(packageAppVersion))) {
CodePushUtils.logBundleUrl(packageFilePath);
isRunningBinaryVersion = false;
return packageFilePath;
} else {
// The binary version is newer.
@@ -167,6 +170,7 @@ public class CodePush {
}
CodePushUtils.logBundleUrl(binaryJsBundleUrl);
isRunningBinaryVersion = true;
return binaryJsBundleUrl;
}
} catch (NumberFormatException e) {
@@ -488,9 +492,7 @@ public class CodePush {
}
}
} else {
String currentPackageHash = null;
currentPackageHash = codePushPackage.getCurrentPackageHash();
if (currentPackageHash == null) {
if (isRunningBinaryVersion) {
// Check if the current appVersion has been reported.
String binaryIdentifier = "" + getBinaryResourcesModifiedTime();
if (isDeploymentStatusNotYetReported(binaryIdentifier)) {