feat: fixed auto update restart

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

@ -24,7 +24,7 @@ async function fetchReleaseFromFSAndUpdateMain(userEd25519SecretKey: Uint8Array)
const diff = Date.now() - lastFetchedTimestamp;
if (diff < skipIfLessThan) {
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;
}

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

Loading…
Cancel
Save