feat: fixed auto update restart

there is a known issue with electron updater quit and install
pull/3281/head
yougotwill 3 months ago
parent 9cf217512f
commit ea47d05044

@ -32,16 +32,20 @@ let stopped = false;
autoUpdater.on(DOWNLOAD_PROGRESS, eventDownloadProgress => { autoUpdater.on(DOWNLOAD_PROGRESS, eventDownloadProgress => {
console.log( console.log(
`[updater] download progress: ${filesize(eventDownloadProgress.transferred, { base: 10 })}/${filesize(eventDownloadProgress.total, { base: 10 })}` `[updater] downloading ${filesize(eventDownloadProgress.transferred, { base: 10 })}/${filesize(eventDownloadProgress.total, { base: 10 })}`
); );
}); });
autoUpdater.on(UPDATE_DOWNLOADED, () => { autoUpdater.on(UPDATE_DOWNLOADED, () => {
isUpdating = true; isUpdating = true;
console.log('[updater] update downloaded'); console.log('[updater] update downloaded');
// https://github.com/electron-userland/electron-builder/issues/6058#issuecomment-1130344017
setTimeout(() => {
console.info('[updater] calling quitAndInstall...'); console.info('[updater] calling quitAndInstall...');
autoUpdater.quitAndInstall(); autoUpdater.quitAndInstall();
app.exit();
isUpdating = false; isUpdating = false;
}, 1000);
}); });
export async function start( export async function start(
@ -206,7 +210,6 @@ async function checkForUpdates(
logger.info('[updater] calling windowMarkShouldQuit...'); logger.info('[updater] calling windowMarkShouldQuit...');
windowMarkShouldQuit(); windowMarkShouldQuit();
logger.info('[updater] UPDATE_DOWNLOADED event should be emitted soon...', UPDATE_DOWNLOADED);
} finally { } finally {
isUpdating = false; isUpdating = false;
} }

Loading…
Cancel
Save