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

Commit 5fe5de8

Browse files
authored
Merge pull request #407 from Microsoft/fix-install-update-twice
No-op in CodePushPackage.m / CodePushUpdateManager.java if the pending update is already installed
2 parents 175fa32 + 31e1b8c commit 5fe5de8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,13 @@ public void downloadPackage(ReadableMap updatePackage, String expectedBundleFile
275275
public void installPackage(ReadableMap updatePackage, boolean removePendingUpdate) {
276276
String packageHash = CodePushUtils.tryGetString(updatePackage, CodePushConstants.PACKAGE_HASH_KEY);
277277
WritableMap info = getCurrentPackageInfo();
278+
279+
String currentPackageHash = CodePushUtils.tryGetString(info, CodePushConstants.CURRENT_PACKAGE_KEY);
280+
if (packageHash != null && packageHash.equals(currentPackageHash)) {
281+
// The current package is already the one being installed, so we should no-op.
282+
return;
283+
}
284+
278285
if (removePendingUpdate) {
279286
String currentPackageFolderPath = getCurrentPackageFolderPath();
280287
if (currentPackageFolderPath != null) {

ios/CodePush/CodePushPackage.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,11 @@ + (void)installPackage:(NSDictionary *)updatePackage
454454
return;
455455
}
456456

457+
if (packageHash && [packageHash isEqualToString:info[@"currentPackage"]]) {
458+
// The current package is already the one being installed, so we should no-op.
459+
return;
460+
}
461+
457462
if (removePendingUpdate) {
458463
NSString *currentPackageFolderPath = [self getCurrentPackageFolderPath:error];
459464
if (!*error && currentPackageFolderPath) {

0 commit comments

Comments
 (0)