#50210: fix: preserve staged update dir when pruning orphaned updates on macOS
Merged
Created: Mar 11, 2026, 12:35:22 PM
Merged: Mar 11, 2026, 5:42:23 PM
8 comments
Target: main
The previous squirrel.mac patch cleaned up all staged update directories before starting a new download. This kept disk usage bounded, but it broke quitAndInstall() if called while a subsequent checkForUpdates() was in flight — the already-staged bundle would be deleted out from under it.
This reworks the patch to:
- Read
ShipItState.plistand preserve the directory it references - Delete only truly orphaned
update.XXXXXXXdirectories - Refactor the enumerate-and-delete logic into a shared helper so the existing
pruneUpdateDirectoriesstill does a full wipe on launch
Disk footprint stays bounded (at most 2 dirs: staged + in-progress) and quitAndInstall() remains safe to call mid-check.
Fixes #50200
Test plan
-
e test --runners=main -g "autoUpdater behavior"passes on macOS - Updated
should preserve the staged update directory and prune orphaned ones when a new update is downloaded— asserts 1 dir during first download, 2 dirs during second (staged preserved + new), and that the original staged dir is among them - New
update-racefixture — callsquitAndInstall()while a secondcheckForUpdates()is downloading; the staged install should succeed - New
update-triple-stackfixture — 3 sequential update downloads without restart; directory count never exceeds 2
Notes: Fixed an issue on macOS where calling autoUpdater.quitAndInstall() could fail if checkForUpdates() was called again after an update was already downloaded.
Backports
Semver Impact
Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron