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

Conversation

@AndrewJack
Copy link
Contributor

@AndrewJack AndrewJack commented Jul 17, 2017

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 /CodePush directory).

Easier to reproduce with InstallMode.ON_NEXT_RESTART

@msftclas
Copy link

@AndrewJack,
Thanks for having already signed the Contribution License Agreement. Your agreement was validated by Microsoft. We will now review your pull request.
Thanks,
Microsoft Pull Request Bot

@max-mironov
Copy link
Contributor

@AndrewJack Great stuff and thanks for taking care of this. Looks good to me.
cc @sergey-akhalkov to also have a look at this before merging

String binaryModifiedDateDuringPackageInstallString = packageMetadata.optString(CodePushConstants.BINARY_MODIFIED_TIME_KEY, null);
if (binaryModifiedDateDuringPackageInstallString != null) {
binaryModifiedDateDuringPackageInstall = Long.parseLong(binaryModifiedDateDuringPackageInstallString);
}
Copy link
Contributor Author

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

Copy link
Contributor

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;
}
Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed!

@sergey-akhalkov
Copy link
Contributor

Hi @AndrewJack, thank you for the contribution, looks good to me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants