MarshallOfSound

#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.plist and preserve the directory it references
  • Delete only truly orphaned update.XXXXXXX directories
  • Refactor the enumerate-and-delete logic into a shared helper so the existing pruneUpdateDirectories still 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-race fixture — calls quitAndInstall() while a second checkForUpdates() is downloading; the staged install should succeed
  • New update-triple-stack fixture — 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

39-x-y
Merged
PR Number
#50215
Merged At
Mar 11, 2026, 8:51:36 PM
Released In
v39.8.1
Release Date
Mar 12, 2026, 7:33:07 AM
40-x-y
Merged
PR Number
#50216
Merged At
Mar 11, 2026, 8:57:23 PM
Released In
v40.8.1
Release Date
Mar 11, 2026, 11:09:49 PM
41-x-y
Merged
PR Number
#50217
Merged At
Mar 11, 2026, 8:50:14 PM
Released In
v41.0.1
Release Date
Mar 11, 2026, 11:13:47 PM

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