fix(update): backup desktop executable before rebuild to prevent loss on build failure#44238
Closed
liuhao1024 wants to merge 1 commit into
Closed
fix(update): backup desktop executable before rebuild to prevent loss on build failure#44238liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
… on build failure electron-builder's before-pack hook deletes the unpacked app directory before staging new binaries. If the build fails (network, cache corruption, etc.), the existing Hermes.exe is lost and desktop shortcuts become dead links. This fix backs up the existing packaged executable directory before the build and restores it on failure. On success, the backup is cleaned up.
Collaborator
Contributor
Author
|
Thanks for the note @alt-glitch. Comparing the two approaches: #44234 uses a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Backs up the existing packaged desktop executable before
hermes updatetriggers an Electron rebuild, and restores it if the build fails. This prevents the desktop shortcut from becoming a dead link whenelectron-builder'sbefore-packhook deletes the unpacked app directory and the subsequent build fails.Related Issue
Fixes #44225
Type of Change
Changes Made
hermes_cli/main.py: Added backup/restore logic around thehermes desktop --build-onlycall in_cmd_update_impl(). Before the build, the existing unpacked app directory is copied to a.baksuffix. On build failure, the backup is restored. On success, the backup is cleaned up.tests/hermes_cli/test_cmd_update.py: AddedTestDesktopBuildBackupRestoreclass with 3 tests covering: build success (backup cleaned up), build failure (backup restored), and no existing executable (no backup attempted).How to Test
python -m pytest tests/hermes_cli/test_cmd_update.py::TestDesktopBuildBackupRestore -vhermes updatewith a simulated build failure (e.g., corrupt Electron cache), verify the desktop executable is preservedChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ACode Intelligence
_cmd_update_impl(callers:cmd_update),_desktop_packaged_executable(callers: 5)hermes updatebefore-pack.cjscleanStaleAppOutDir()deletes unpacked dir; this fix adds a Python-side safety net