fix(desktop): preserve previous unpacked dir on failed pack (rename instead of delete)#39427
Closed
alaamohanad169-ship-it wants to merge 2 commits into
Closed
fix(desktop): preserve previous unpacked dir on failed pack (rename instead of delete)#39427alaamohanad169-ship-it wants to merge 2 commits into
alaamohanad169-ship-it wants to merge 2 commits into
Conversation
ca82c7b to
95dfae7
Compare
…nstead of delete) The before-pack hook was deleting the old unpacked app directory before staging a fresh one. If the build failed after that deletion, the user was left with no working app at all — the prior version gone and no replacement. Now the hook renames the previous appOutDir to a .backup directory instead of deleting it. The after-pack hook removes the backup on success; if the build is interrupted or fails, the backup persists and is cleaned up by the next run's before-pack. Fixes the reliability half of issue NousResearch#39404 (the TS2411 type error was already fixed by d29caf3). Test: 5/5 before-pack tests pass (stash, no-op, invalid input, stale backup cleanup, graceful error handling).
95dfae7 to
0f1c030
Compare
Contributor
Author
|
Updated: The doctor no-lockfile change has been split into a separate PR (#39449). This PR now contains only the desktop build fix (rename-to-backup). The unused |
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 this fixes
Part 2 of issue #39404 (the TS2411 type error was already fixed by d29caf3).
Problem
The before-pack.cjs hook deleted the old win-unpacked/linux-unpacked/mac-unpacked directory before electron-builder staged a fresh one. If the build step failed after the deletion (type error, OOM, Ctrl-C), the user was left with no working app at all.
Fix
.backupviafs.renameSync. Rename is near-atomic on the same filesystem..backupdir.Testing
Notes
Draft PR — logic is platform-agnostic (fs.renameSync works cross-platform). A maintainer should verify on Windows/macOS before merging.