diff --git a/src/main/index.js b/src/main/index.js index a1947739d..d2c30e2b0 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -14,15 +14,6 @@ import createWindow from './createWindow'; autoUpdater.autoDownload = true; -// This is set to true if an auto update has been downloaded through the Electron -// auto-update system and is ready to install. If the user declined an update earlier, -// it will still install on shutdown. -let autoUpdateDownloaded = false; - -// This is used to keep track of whether we are showing the special dialog -// that we show on Windows after you decline an upgrade and close the app later. -let showingAutoUpdateCloseAlert = false; - // Keep a global reference, if you don't, they will be closed automatically when the JavaScript // object is garbage collected. let rendererWindow; @@ -84,16 +75,16 @@ app.on('activate', () => { app.on('will-quit', event => { if ( process.platform === 'win32' && - autoUpdateDownloaded && + appState.autoUpdateDownloaded && !appState.autoUpdateAccepted && - !showingAutoUpdateCloseAlert + !appState.showingAutoUpdateCloseAlert ) { - // We're on Win and have an update downloaded, but the user declined it (or closed + // We're on Win and have an update downloaded, but the user postponed it (or closed // the app without accepting it). Now the user is closing the app, so the new update // will install. On Mac this is silent, but on Windows they get a confusing permission // escalation dialog, so we show Windows users a warning dialog first. - showingAutoUpdateCloseAlert = true; + appState.showingAutoUpdateCloseAlert = true; dialog.showMessageBox( { type: 'info', @@ -126,6 +117,9 @@ app.on('will-finish-launching', () => { app.on('before-quit', () => { appState.isQuitting = true; + if (appState.autoUpdateAccepted) { + if (daemon) daemon.quit(); + } }); ipcMain.on('upgrade', (event, installerPath) => { @@ -145,7 +139,7 @@ ipcMain.on('upgrade', (event, installerPath) => { }); autoUpdater.on('update-downloaded', () => { - autoUpdateDownloaded = true; + appState.autoUpdateDownloaded = true; }); ipcMain.on('autoUpdateAccepted', () => {