({ alertOnFail }: UpdateCheckOptions)
| 872 | } |
| 873 | |
| 874 | const runUpdateCheck = async ({ alertOnFail }: UpdateCheckOptions) => { |
| 875 | if (!app.isPackaged) { |
| 876 | if (alertOnFail) { |
| 877 | await dialog.showMessageBox({ |
| 878 | type: "info", |
| 879 | title: "Updates unavailable", |
| 880 | message: "Auto-update is only enabled in packaged builds.", |
| 881 | }); |
| 882 | } |
| 883 | return; |
| 884 | } |
| 885 | if (downloadedUpdateVersion) { |
| 886 | await promptInstallUpdate(downloadedUpdateVersion); |
| 887 | return; |
| 888 | } |
| 889 | // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: surface network/update failures only when the user asked |
| 890 | try { |
| 891 | const result = await autoUpdater.checkForUpdates(); |
| 892 | const newer = result?.isUpdateAvailable === true; |
| 893 | if (!alertOnFail) return; |
| 894 | if (newer) return; // 'update-downloaded' handler will fire the install dialog |
| 895 | await dialog.showMessageBox({ |
| 896 | type: "info", |
| 897 | title: "No updates", |
| 898 | message: `You're on the latest version (${app.getVersion()}).`, |
| 899 | }); |
| 900 | } catch (error) { |
| 901 | log.warn("[updater] check failed", error); |
| 902 | if (!alertOnFail) return; |
| 903 | await dialog.showMessageBox({ |
| 904 | type: "error", |
| 905 | title: "Update check failed", |
| 906 | message: "Couldn't reach the update server.", |
| 907 | detail: "Check your network and try again from the menu.", |
| 908 | }); |
| 909 | } |
| 910 | }; |
| 911 | |
| 912 | // A sidecar that can't boot usually means a broken build or an incompatible |
| 913 | // data dir — both states the user can't see from a dock icon that bounces |
no test coverage detected