MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / runUpdateCheck

Function runUpdateCheck

apps/desktop/src/main/index.ts:1016–1064  ·  view source on GitHub ↗
({ alertOnFail, trigger }: UpdateCheckOptions)

Source from the content-addressed store, hash-verified

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

Callers 5

registerIpcHandlersFunction · 0.85
setupAutoUpdaterFunction · 0.85
installApplicationMenuFunction · 0.85
bootFunction · 0.85

Calls 6

planUpdateCheckFunction · 0.90
planCompletedUpdateCheckFunction · 0.90
statusAfterUpdateErrorFunction · 0.90
promptInstallUpdateFunction · 0.85
setUpdateStatusFunction · 0.85
warnMethod · 0.80

Tested by

no test coverage detected