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

Commit d57066b

Browse files
MAKARDMAKARD01
andauthored
fix: Clear updates on initializeUpdateAfterRestart in case codepush.json is corrupted (#2668)
* fix: Clear updates on initializeUpdateAfterRestart in case codepush.json is corrupted * fix: Log the complete error instead of only message --------- Co-authored-by: MAKARD01 <dmytro.makarenko@kingfisher.com>
1 parent 6899e68 commit d57066b

File tree

1 file changed

+10
-1
lines changed
  • android/app/src/main/java/com/microsoft/codepush/react

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,16 @@ void initializeUpdateAfterRestart() {
295295

296296
JSONObject pendingUpdate = mSettingsManager.getPendingUpdate();
297297
if (pendingUpdate != null) {
298-
JSONObject packageMetadata = this.mUpdateManager.getCurrentPackage();
298+
JSONObject packageMetadata = null;
299+
300+
try {
301+
packageMetadata = this.mUpdateManager.getCurrentPackage();
302+
} catch (CodePushMalformedDataException e) {
303+
// We need to recover the app in case 'codepush.json' is corrupted
304+
CodePushUtils.log(e);
305+
clearUpdates();
306+
return;
307+
}
299308
if (packageMetadata == null || !isPackageBundleLatest(packageMetadata) && hasBinaryVersionChanged(packageMetadata)) {
300309
CodePushUtils.log("Skipping initializeUpdateAfterRestart(), binary version is newer");
301310
return;

0 commit comments

Comments
 (0)