fix(desktop): avoid relaunching without installing updates (#23806)
This commit is contained in:
parent
3bfe6a1ef6
commit
2e156b8990
7 changed files with 34 additions and 19 deletions
|
|
@ -337,11 +337,16 @@ function setupAutoUpdater() {
|
|||
})
|
||||
}
|
||||
|
||||
let updateReady = false
|
||||
let downloadedUpdateVersion: string | undefined
|
||||
|
||||
async function checkUpdate() {
|
||||
if (!UPDATER_ENABLED) return { updateAvailable: false }
|
||||
updateReady = false
|
||||
if (downloadedUpdateVersion) {
|
||||
logger.log("returning cached downloaded update", {
|
||||
version: downloadedUpdateVersion,
|
||||
})
|
||||
return { updateAvailable: true, version: downloadedUpdateVersion }
|
||||
}
|
||||
logger.log("checking for updates", {
|
||||
currentVersion: app.getVersion(),
|
||||
channel: autoUpdater.channel,
|
||||
|
|
@ -367,7 +372,7 @@ async function checkUpdate() {
|
|||
logger.log("update available", { version })
|
||||
await autoUpdater.downloadUpdate()
|
||||
logger.log("update download completed", { version })
|
||||
updateReady = true
|
||||
downloadedUpdateVersion = version
|
||||
return { updateAvailable: true, version }
|
||||
} catch (error) {
|
||||
logger.error("update check failed", error)
|
||||
|
|
@ -376,7 +381,15 @@ async function checkUpdate() {
|
|||
}
|
||||
|
||||
async function installUpdate() {
|
||||
if (!updateReady) return
|
||||
if (!downloadedUpdateVersion) {
|
||||
logger.log("install update skipped", {
|
||||
reason: "no downloaded update ready",
|
||||
})
|
||||
return
|
||||
}
|
||||
logger.log("installing downloaded update", {
|
||||
version: downloadedUpdateVersion,
|
||||
})
|
||||
killSidecar()
|
||||
autoUpdater.quitAndInstall()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ const createPlatform = (): Platform => {
|
|||
return window.api.checkUpdate()
|
||||
},
|
||||
|
||||
update: async () => {
|
||||
updateAndRestart: async () => {
|
||||
const config = await window.api.getWindowConfig().catch(() => ({ updaterEnabled: false }))
|
||||
if (!config.updaterEnabled) return
|
||||
await window.api.installUpdate()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue