mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-11 08:04:23 +08:00
Handle codepush.json parsing exception (#1540)
This commit is contained in:
committed by
Alexander Goncharov
parent
137067c45a
commit
964530c7c2
@@ -213,7 +213,15 @@ public class CodePush implements ReactPackage {
|
||||
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);
|
||||
|
||||
@@ -349,6 +349,11 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user