Skip to content

Commit

Permalink
Handle codepush.json parsing exception (#1540)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuri Kulikov authored and alexandergoncharov-zz committed Mar 15, 2019
1 parent 137067c commit 964530c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,15 @@ public String getJSBundleFileInternal(String assetsBundleFileName) {
this.mAssetsBundleFileName = assetsBundleFileName;
String binaryJsBundleUrl = CodePushConstants.ASSETS_BUNDLE_PREFIX + assetsBundleFileName;

String packageFilePath = mUpdateManager.getCurrentPackageBundlePath(this.mAssetsBundleFileName);
String packageFilePath = null;
try {
packageFilePath = mUpdateManager.getCurrentPackageBundlePath(this.mAssetsBundleFileName);
} catch (CodePushMalformedDataException e) {
// We need to recover the app in case 'codepush.json' is corrupted
CodePushUtils.log(e.getMessage());
clearUpdates();
}

if (packageFilePath == null) {
// There has not been any downloaded updates.
CodePushUtils.logBundleUrl(binaryJsBundleUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,11 @@ protected Void doInBackground(Void... params) {
CodePushUtils.setJSONValueForKey(currentPackage, "isPending", currentUpdateIsPending);
promise.resolve(CodePushUtils.convertJsonObjectToWritable(currentPackage));
}
} catch (CodePushMalformedDataException e) {
// We need to recover the app in case 'codepush.json' is corrupted
CodePushUtils.log(e.getMessage());
clearUpdates();
promise.resolve(null);
} catch(CodePushUnknownException e) {
CodePushUtils.log(e);
promise.reject(e);
Expand Down

0 comments on commit 964530c

Please sign in to comment.