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

@ -24,7 +24,7 @@ async function fetchReleaseFromFSAndUpdateMain(userEd25519SecretKey: Uint8Array)
const diff = Date.now() - lastFetchedTimestamp; const diff = Date.now() - lastFetchedTimestamp;
if (diff < skipIfLessThan) { if (diff < skipIfLessThan) {
window.log.info( window.log.info(
`[updater] fetched release from fs ${Math.floor(diff / DURATION.MINUTES)}minutes ago, skipping until that's at least ${Math.floor(skipIfLessThan / DURATION.MINUTES)}` `[updater] fetched release from fs ${Math.floor(diff / DURATION.MINUTES)} minutes ago, skipping until that's at least ${Math.floor(skipIfLessThan / DURATION.MINUTES)}`
); );
return; return;
} }

@ -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');
console.info('[updater] calling quitAndInstall...'); // https://github.com/electron-userland/electron-builder/issues/6058#issuecomment-1130344017
autoUpdater.quitAndInstall(); setTimeout(() => {
isUpdating = false; console.info('[updater] calling quitAndInstall...');
autoUpdater.quitAndInstall();
app.exit();
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