From 13a375321463c712061c49a396f53fa11c679c08 Mon Sep 17 00:00:00 2001 From: rafael-aero Date: Wed, 9 Feb 2022 22:18:04 +0100 Subject: [PATCH] emit prepare-for-update --- ElectronNET.API/AutoUpdater.cs | 1 + ElectronNET.Host/main.js | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ElectronNET.API/AutoUpdater.cs b/ElectronNET.API/AutoUpdater.cs index 038981c..2053d8d 100644 --- a/ElectronNET.API/AutoUpdater.cs +++ b/ElectronNET.API/AutoUpdater.cs @@ -426,6 +426,7 @@ namespace ElectronNET.API /// Run the app after finish even on silent install. Not applicable for macOS. Ignored if `isSilent` is set to `false`. public void QuitAndInstall(bool isSilent = false, bool isForceRunAfter = false) { + BridgeConnector.EmitSync("prepare-for-update"); BridgeConnector.EmitSync("autoUpdaterQuitAndInstall", isSilent, isForceRunAfter); } diff --git a/ElectronNET.Host/main.js b/ElectronNET.Host/main.js index dab996b..99f6809 100644 --- a/ElectronNET.Host/main.js +++ b/ElectronNET.Host/main.js @@ -54,7 +54,7 @@ app.on('will-finish-launching', () => { }) }); -app.on('before-quit-for-update', () => { +function prepareForUpdate() { ignoreApiProcessClosed = true; app.removeAllListeners("window-all-closed"); @@ -73,7 +73,9 @@ app.on('before-quit-for-update', () => { } }); } -}); +} + +app.on('before-quit-for-update', () => { prepareForUpdate(); }); const manifestJsonFile = require(manifestJsonFilePath); @@ -307,6 +309,8 @@ function startSocketApiBridge(port) { } }); + socket.on('prepare-for-update', () => { prepareForUpdate(); }); + socket.on('register-app-open-file-event', (id) => { global['electronsocket'] = socket;