From b82cb0e849ae9f0f42df73efcad1ffc411c3f9f4 Mon Sep 17 00:00:00 2001 From: antelle Date: Sun, 10 Jan 2021 09:28:09 +0100 Subject: [PATCH] fixed Windows update installation --- desktop/main.js | 1 - desktop/scripts/update-installer.js | 12 +++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/desktop/main.js b/desktop/main.js index b00e7daa..a33e5638 100644 --- a/desktop/main.js +++ b/desktop/main.js @@ -951,6 +951,5 @@ function exitAndStartUpdate() { if (pendingUpdateFilePath) { const { installUpdate } = require('./scripts/update-installer'); installUpdate(pendingUpdateFilePath); - main.exit(0); } } diff --git a/desktop/scripts/update-installer.js b/desktop/scripts/update-installer.js index 2b4b0405..51dcb0c4 100644 --- a/desktop/scripts/update-installer.js +++ b/desktop/scripts/update-installer.js @@ -38,6 +38,8 @@ function installDarwinUpdate(updateFilePath) { `--dmg=${updateFilePath}`, `--app=${appPath}` ]); + + electron.app.exit(0); } function installWin32Update(updateFilePath) { @@ -48,16 +50,16 @@ function installWin32Update(updateFilePath) { const appDir = path.dirname(electron.app.getPath('exe')); const updateCommand = `"${updateFilePath}" /U1 /D=${appDir}`; - const tempPath = path.join(electron.app.getPath('temp'), 'KeeWeb'); - const updateLauncherScriptPath = path.join(tempPath, 'update-keeweb.cmd'); - fs.writeFileSync(updateLauncherScriptPath, updateCommand); - - spawnDetached(updateLauncherScriptPath); + const ps = spawnDetached('cmd'); + ps.stdin.end(`${updateCommand}\nexit\n`, 'utf8', () => { + electron.app.exit(0); + }); } function spawnDetached(command, args) { const ps = spawn(command, args || [], { detached: true }); ps.unref(); + return ps; } module.exports.installUpdate = installUpdate;