fix: make core self-updates atomic on macOS - #3124
Open
LovePeachBlossom wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the core self-update flow to avoid executable truncation/corruption (notably on macOS) by staging updates next to the target binary, syncing/signing/verifying, and then performing an atomic replacement with backup/rollback support.
Changes:
- Resolve symlinks for the current executable and replace the in-place copy logic with a staged + atomic rename workflow.
- Add cross-platform helpers for signing/verification (darwin), directory/file syncing, and ownership/mode preservation.
- Add unit tests covering failure modes (copy/sign/rename), successful replacement cleanup, ownership preservation, and rollback.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| component/updater/update_core.go | Reworks Update() to stage/sign/verify then atomically replace; improves backup and adds rollback path. |
| component/updater/update_core_file.go | Introduces shared atomic stage/commit helpers, metadata preservation, and stale staged-file cleanup. |
| component/updater/update_core_sign_darwin.go | Implements macOS codesign signing/verification for staged binaries. |
| component/updater/update_core_sign_other.go | No-op signing/verification on non-darwin platforms. |
| component/updater/update_core_sync_unix.go | Adds Unix file/directory syncing helpers (fsync) for durability. |
| component/updater/update_core_sync_windows.go | Windows-specific sync stubs aligned with Windows behavior constraints. |
| component/updater/update_core_sync_other.go | No-op sync helpers for unsupported/other platforms. |
| component/updater/update_core_owner_unix.go | Captures/applies uid/gid ownership for Unix-like platforms with permission-aware behavior. |
| component/updater/update_core_owner_other.go | Ownership stubs for non-Unix platforms. |
| component/updater/update_core_test.go | Adds unit tests for atomic replacement behavior and cleanup guarantees. |
| component/updater/update_core_owner_unix_test.go | Adds Unix-only tests for ownership and backup metadata preservation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Summary
Testing
with_gvisortag.