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

Commit 88b7fb3

Browse files
committed
isRunningBinary
1 parent d20e9cc commit 88b7fb3

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

CodePush.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ @implementation CodePush {
1414
RCT_EXPORT_MODULE()
1515

1616
static BOOL didRollback = NO;
17+
static BOOL isRunningBinaryVersion = NO;
1718
static BOOL testConfigurationFlag = NO;
1819

1920
// These constants represent valid deployment statuses
@@ -62,6 +63,7 @@ + (NSURL *)bundleURLForResource:(NSString *)resourceName
6263

6364
if (error || !packageFile) {
6465
NSLog(logMessageFormat, binaryJsBundleUrl);
66+
isRunningBinaryVersion = YES;
6567
return binaryJsBundleUrl;
6668
}
6769

@@ -73,6 +75,7 @@ + (NSURL *)bundleURLForResource:(NSString *)resourceName
7375
NSDictionary *currentPackageMetadata = [CodePushPackage getCurrentPackage:&error];
7476
if (error || !currentPackageMetadata) {
7577
NSLog(logMessageFormat, binaryJsBundleUrl);
78+
isRunningBinaryVersion = YES;
7679
return binaryJsBundleUrl;
7780
}
7881

@@ -82,13 +85,15 @@ + (NSURL *)bundleURLForResource:(NSString *)resourceName
8285
// Return package file because it is newer than the app store binary's JS bundle
8386
NSURL *packageUrl = [[NSURL alloc] initFileURLWithPath:packageFile];
8487
NSLog(logMessageFormat, packageUrl);
88+
isRunningBinaryVersion = NO;
8589
return packageUrl;
8690
} else {
8791
#ifndef DEBUG
8892
[CodePush clearUpdates];
8993
#endif
9094

9195
NSLog(logMessageFormat, binaryJsBundleUrl);
96+
isRunningBinaryVersion = YES;
9297
return binaryJsBundleUrl;
9398
}
9499
}
@@ -557,9 +562,7 @@ - (void)savePendingUpdate:(NSString *)packageHash
557562
}
558563
}
559564
} else {
560-
NSError *error;
561-
NSString *currentPackageHash = [CodePushPackage getCurrentPackageHash:&error];
562-
if (error || currentPackageHash == nil) {
565+
if (isRunningBinaryVersion) {
563566
// Check if the current appVersion has been reported. Use date as the binary identifier to
564567
// handle binary releases that do not modify the appVersion.
565568
NSURL *binaryJsBundleUrl = [CodePush bundleURL];

android/app/src/main/java/com/microsoft/codepush/react/CodePush.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@
4040

4141
public class CodePush {
4242

43-
private static boolean testConfigurationFlag = false;
4443
private static boolean didRollback = false;
44+
private static boolean isRunningBinaryVersion = false;
45+
private static boolean testConfigurationFlag = false;
4546

4647
private boolean didUpdate = false;
4748

@@ -143,6 +144,7 @@ public String getBundleUrl(String assetsBundleFileName) {
143144
if (packageFilePath == null) {
144145
// There has not been any downloaded updates.
145146
CodePushUtils.logBundleUrl(binaryJsBundleUrl);
147+
isRunningBinaryVersion = true;
146148
return binaryJsBundleUrl;
147149
}
148150

@@ -158,6 +160,7 @@ public String getBundleUrl(String assetsBundleFileName) {
158160
binaryModifiedDateDuringPackageInstall == binaryResourcesModifiedTime &&
159161
(this.isUsingTestConfiguration() || this.appVersion.equals(packageAppVersion))) {
160162
CodePushUtils.logBundleUrl(packageFilePath);
163+
isRunningBinaryVersion = false;
161164
return packageFilePath;
162165
} else {
163166
// The binary version is newer.
@@ -167,6 +170,7 @@ public String getBundleUrl(String assetsBundleFileName) {
167170
}
168171

169172
CodePushUtils.logBundleUrl(binaryJsBundleUrl);
173+
isRunningBinaryVersion = true;
170174
return binaryJsBundleUrl;
171175
}
172176
} catch (NumberFormatException e) {
@@ -488,9 +492,7 @@ public void getNewStatusReport(Promise promise) {
488492
}
489493
}
490494
} else {
491-
String currentPackageHash = null;
492-
currentPackageHash = codePushPackage.getCurrentPackageHash();
493-
if (currentPackageHash == null) {
495+
if (isRunningBinaryVersion) {
494496
// Check if the current appVersion has been reported.
495497
String binaryIdentifier = "" + getBinaryResourcesModifiedTime();
496498
if (isDeploymentStatusNotYetReported(binaryIdentifier)) {

0 commit comments

Comments
 (0)