({ alertOnFail, trigger }: UpdateCheckOptions)
| 1013 | }; |
| 1014 | |
| 1015 | const runUpdateCheck = async ({ alertOnFail, trigger }: UpdateCheckOptions) => { |
| 1016 | if (!app.isPackaged) { |
| 1017 | if (alertOnFail) { |
| 1018 | await dialog.showMessageBox({ |
| 1019 | type: "info", |
| 1020 | title: "Updates unavailable", |
| 1021 | message: "Auto-update is only enabled in packaged builds.", |
| 1022 | }); |
| 1023 | } |
| 1024 | return; |
| 1025 | } |
| 1026 | const checkPlan = planUpdateCheck({ stagedVersion: downloadedUpdateVersion, trigger }); |
| 1027 | if (!checkPlan.check) return; |
| 1028 | // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: surface network/update failures only when the user asked |
| 1029 | try { |
| 1030 | const result = (await autoUpdater.checkForUpdates()) as UpdateCheckResult | null; |
| 1031 | const newer = result?.isUpdateAvailable === true; |
| 1032 | const promptAfterCheck = planCompletedUpdateCheck({ |
| 1033 | stagedVersion: checkPlan.promptVersionAfterCheck, |
| 1034 | trigger, |
| 1035 | updateAvailable: newer, |
| 1036 | availableVersion: |
| 1037 | typeof result?.updateInfo?.version === "string" ? result.updateInfo.version : null, |
| 1038 | }).promptVersion; |
| 1039 | if (promptAfterCheck) { |
| 1040 | await promptInstallUpdate(promptAfterCheck); |
| 1041 | return; |
| 1042 | } |
| 1043 | if (!alertOnFail) return; |
| 1044 | if (newer) return; // 'update-downloaded' handler will fire the install dialog |
| 1045 | await dialog.showMessageBox({ |
| 1046 | type: "info", |
| 1047 | title: "No updates", |
| 1048 | message: `You're on the latest version (${app.getVersion()}).`, |
| 1049 | }); |
| 1050 | } catch (error) { |
| 1051 | log.warn("[updater] check failed", error); |
| 1052 | setUpdateStatus( |
| 1053 | statusAfterUpdateError(updateStatus, "Update failed. Check again from the menu."), |
| 1054 | ); |
| 1055 | if (!alertOnFail) return; |
| 1056 | await dialog.showMessageBox({ |
| 1057 | type: "error", |
| 1058 | title: "Update check failed", |
| 1059 | message: "Couldn't reach the update server.", |
| 1060 | detail: "Check your network and try again from the menu.", |
| 1061 | }); |
| 1062 | } |
| 1063 | }; |
| 1064 | |
| 1065 | // A sidecar that can't boot usually means a broken build or an incompatible |
| 1066 | // data dir — both states the user can't see from a dock icon that bounces |
no test coverage detected