Skip to content

Commit ba353e6

Browse files
MAKARDMAKARD01
authored andcommitted
fix: Clear updates on initializeUpdateAfterRestart in case codepush.json is corrupted (microsoft#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> (cherry picked from commit d57066b)
1 parent 9102ea3 commit ba353e6

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)