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

Function runUpdateCheck

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

Source from the content-addressed store, hash-verified

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