fix(cli): restore previous extension on failed update#26930
Conversation
If loadExtension or any of the file operations after the destructive uninstall step (mkdir, copy, metadata write, integrity check, load) failed during an extension update, the user was left without a working extension. The existing code carried a TODO acknowledging this gap. Snapshot the previous extension directory into a temp dir before the uninstall+copy sequence, and on any update failure rm the partial new destination and restore the previous version from the snapshot. The snapshot is unconditionally cleaned up in finally on both success and failure paths. Fixes google-gemini#21671
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request improves the reliability of the extension update process by introducing a rollback mechanism. By creating a temporary snapshot of the current extension before applying updates, the system can now gracefully recover if any part of the installation sequence fails, preventing users from being left with a non-functional extension. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
Summary
If
loadExtensionor any of the file operations after the destructive uninstall step (mkdir,copyExtension, metadata write, integrity check, load)failed during an extension update, the user was left without a working extension. A pre-existing TODO at the
loadExtensioncall site alreadyacknowledged this gap.
Snapshot the previous extension directory into a temp dir (via
ExtensionStorage.createTmpDir()) before the destructive sequence. On any update failure,rm -rfthe partial new destination andcopyExtensionthe snapshot back into the original location. The snapshot is unconditionally cleaned up infinallyon both success and failure paths.The broader (uninstall → copy → metadata → integrity → load) window is covered, not just the load step the TODO pointed at — any of those steps failing
equally orphans the user.
Fixes #21671
Test plan
npm run preflightexit 0