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

Function runUpdateCheck

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

Source from the content-addressed store, hash-verified

965};
966
967const 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

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