-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Prevent Rollback crash when binary was updated. #924
Prevent Rollback crash when binary was updated. #924
Conversation
|
@AndrewJack, |
|
@AndrewJack Great stuff and thanks for taking care of this. Looks good to me. |
| String binaryModifiedDateDuringPackageInstallString = packageMetadata.optString(CodePushConstants.BINARY_MODIFIED_TIME_KEY, null); | ||
| if (binaryModifiedDateDuringPackageInstallString != null) { | ||
| binaryModifiedDateDuringPackageInstall = Long.parseLong(binaryModifiedDateDuringPackageInstallString); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah just spotted this - The NumberFormatException should be caught
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aye, good note, and it can be moved away from getJSBundleFileInternal method probably
| if (!isPackageBundleLatest(packageMetadata) && hasBinaryVersionChanged(packageMetadata)) { | ||
| CodePushUtils.log("Skipping initializeUpdateAfterRestart(), binary version is newer"); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I move this inside if (pendingUpdate != null) { to avoid reading the file getCurrentPackage file every time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed!
|
Hi @AndrewJack, thank you for the contribution, looks good to me. |
Fixes: #921
Senario:
When a code push update failed (rollback on next start), but the binary version was updated before the next restart.
This causes a the initialisation code to start a rollback, and clear the previous update at the same time causing IO crashes due to the unexpected state (deleted
/CodePushdirectory).Easier to reproduce with
InstallMode.ON_NEXT_RESTART