Fix Windows auto updater file locking issue

Implement deferred update mechanism using a helper batch script that applies
updates after the application exits, avoiding Windows file locking issues.

On Windows, the updater now:
- Stages update files and creates a helper batch script
- Launches the script as a detached process
- Exits the application
- The script waits for app closure, applies updates, and restarts Citron

Linux AppImage updates continue to work as before with the existing method.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
This commit is contained in:
Zephyron
2025-11-01 19:19:02 +10:00
parent a462e66927
commit 0ce89925a2
4 changed files with 141 additions and 1 deletions

View File

@@ -6069,8 +6069,22 @@ int main(int argc, char* argv[]) {
#endif
#ifdef CITRON_USE_AUTO_UPDATER
// Check for and apply staged updates before starting the main application
std::filesystem::path app_dir = std::filesystem::path(QCoreApplication::applicationDirPath().toStdString());
#ifdef _WIN32
// On Windows, updates are applied by the helper script after the app exits.
// If we find a staging directory here, it means the helper script failed.
// Clean it up to avoid confusion.
std::filesystem::path staging_path = app_dir / "update_staging";
if (std::filesystem::exists(staging_path)) {
try {
std::filesystem::remove_all(staging_path);
} catch (...) {
// Ignore cleanup errors
}
}
#else
// On Linux, apply staged updates at startup as before
if (Updater::UpdaterService::HasStagedUpdate(app_dir)) {
if (Updater::UpdaterService::ApplyStagedUpdate(app_dir)) {
// Show a simple message that update was applied
@@ -6079,6 +6093,7 @@ int main(int argc, char* argv[]) {
}
}
#endif
#endif
#ifdef _WIN32
OverrideWindowsFont();