fixed Windows update installation

This commit is contained in:
antelle 2021-01-10 09:28:09 +01:00
parent c44a8fab42
commit b82cb0e849
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
2 changed files with 7 additions and 6 deletions

View File

@ -951,6 +951,5 @@ function exitAndStartUpdate() {
if (pendingUpdateFilePath) {
const { installUpdate } = require('./scripts/update-installer');
installUpdate(pendingUpdateFilePath);
main.exit(0);
}
}

View File

@ -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;