({ alertOnFail, trigger }: UpdateCheckOptions)
| 965 | }; |
| 966 | |
| 967 | const runUpdateCheck = async ({ alertOnFail, trigger }: UpdateCheckOptions) => { |
| 968 | if (!app.isPackaged) { |
| 969 | if (alertOnFail) { |
| 970 | await dialog.showMessageBox({ |
| 971 | type: "info", |
| 972 | title: "Updates unavailable", |
| 973 | message: "Auto-update is only enabled in packaged builds.", |
| 974 | }); |
| 975 | } |
| 976 | return; |
| 977 | } |
| 978 | const checkPlan = planUpdateCheck({ stagedVersion: downloadedUpdateVersion, trigger }); |
| 979 | if (!checkPlan.check) return; |
| 980 | // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: surface network/update failures only when the user asked |
| 981 | try { |
| 982 | const result = (await autoUpdater.checkForUpdates()) as UpdateCheckResult | null; |
| 983 | const newer = result?.isUpdateAvailable === true; |
| 984 | const promptAfterCheck = planCompletedUpdateCheck({ |
| 985 | stagedVersion: checkPlan.promptVersionAfterCheck, |
| 986 | trigger, |
| 987 | updateAvailable: newer, |
| 988 | availableVersion: |
| 989 | typeof result?.updateInfo?.version === "string" ? result.updateInfo.version : null, |
| 990 | }).promptVersion; |
| 991 | if (promptAfterCheck) { |
| 992 | await promptInstallUpdate(promptAfterCheck); |
| 993 | return; |
| 994 | } |
| 995 | if (!alertOnFail) return; |
| 996 | if (newer) return; // 'update-downloaded' handler will fire the install dialog |
| 997 | await dialog.showMessageBox({ |
| 998 | type: "info", |
| 999 | title: "No updates", |
| 1000 | message: `You're on the latest version (${app.getVersion()}).`, |
| 1001 | }); |
| 1002 | } catch (error) { |
| 1003 | log.warn("[updater] check failed", error); |
| 1004 | setUpdateStatus( |
| 1005 | statusAfterUpdateError(updateStatus, "Update failed. Check again from the menu."), |
| 1006 | ); |
| 1007 | if (!alertOnFail) return; |
| 1008 | await dialog.showMessageBox({ |
| 1009 | type: "error", |
| 1010 | title: "Update check failed", |
| 1011 | message: "Couldn't reach the update server.", |
| 1012 | detail: "Check your network and try again from the menu.", |
| 1013 | }); |
| 1014 | } |
| 1015 | }; |
| 1016 | |
| 1017 | // A sidecar that can't boot usually means a broken build or an incompatible |
| 1018 | // data dir — both states the user can't see from a dock icon that bounces |
no test coverage detected