Skip to content

Prevent crashes from partial in-place updates#4868

Merged
Gabriel Dufresne (GabrielDuf) merged 2 commits into
mainfrom
update
Jun 3, 2026
Merged

Prevent crashes from partial in-place updates#4868
Gabriel Dufresne (GabrielDuf) merged 2 commits into
mainfrom
update

Conversation

@GabrielDuf
Copy link
Copy Markdown
Contributor

This pull request introduces a mechanism to prevent application launches during in-progress updates, ensuring that UniGetUI does not start while its binaries are being replaced. It adds a file-based update-in-progress marker, logic to create and remove the marker during installation, and guards in both the Avalonia and classic entry points to abort startup if an update is detected. The update detection logic is fully tested, and installer process handling is improved to reliably terminate running instances and avoid file lock issues.

Update-in-progress detection and prevention:

  • Added UpdateInProgressGuard class to UniGetUI.Core.Data that detects the presence of an update-in-progress marker file and blocks UI startup if an update is underway. The guard checks both the current and parent directories, ignores stale markers, and is used by both the Avalonia and classic entry points (UpdateInProgressGuard.cs, EntryPoint.cs, Program.cs).
  • Added comprehensive tests for UpdateInProgressGuard to ensure correct detection logic, marker cleanup, and contract with the installer (UpdateInProgressGuardTests.cs).
  • Exposed internals of UniGetUI.Core.Data to the test assembly via InternalsVisibleTo (InternalsVisibleTo.cs).

Installer improvements and integration:

  • Modified the installer script (UniGetUI.iss) to write the update-in-progress marker before copying files and remove it after installation, ensuring that any instance launched mid-update will abort. The marker file name is kept in sync with the guard logic.
  • Improved process handling in the installer: replaced the old TaskKill with a new TaskKillWait that reliably kills all relevant processes (including helpers), and set CloseApplications=force to forcibly close any processes holding files to be overwritten.

Installer deployment changes:

  • Updated the installer to avoid redundant calls to kill running apps, since this is now handled in PrepareToInstall.

These changes collectively make UniGetUI more robust during updates, preventing accidental launches into a partially updated state and improving reliability.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces an “update-in-progress” marker mechanism so UniGetUI won’t start while an in-place installer update is actively swapping binaries, reducing the risk of launching into a partially updated state.

Changes:

  • Adds an UpdateInProgressGuard in UniGetUI.Core.Data and integrates it into both WinUI and Avalonia entry points to abort UI startup during updates.
  • Updates the Inno Setup installer to create/remove an update marker around the file copy window and improves process termination prior to install.
  • Adds unit tests for the guard and exposes internals to the test assembly.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
UniGetUI.iss Adds update marker lifecycle in installer + improved process-kill behavior and close-apps configuration.
src/UniGetUI/EntryPoint.cs Blocks WinUI startup when an update marker is detected.
src/UniGetUI.Core.Data/UpdateInProgressGuard.cs New guard that detects (and optionally cleans) the update marker in base/parent directories.
src/UniGetUI.Core.Data/InternalsVisibleTo.cs Allows the test project to call internal guard overloads.
src/UniGetUI.Core.Data.Tests/UpdateInProgressGuardTests.cs Adds tests validating marker detection/cleanup and the installer contract.
src/UniGetUI.Avalonia/Program.cs Blocks Avalonia startup when an update marker is detected.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/UniGetUI.Core.Data/UpdateInProgressGuard.cs Outdated
Comment thread src/UniGetUI.Core.Data.Tests/UpdateInProgressGuardTests.cs Outdated
@GabrielDuf Gabriel Dufresne (GabrielDuf) merged commit 2187aa4 into main Jun 3, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants