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

Function setupAutoUpdater

apps/desktop/src/main/index.ts:836–868  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

834const UPDATE_POLL_INTERVAL_MS = 4 * 60 * 60 * 1000; // 4 hours
835
836const setupAutoUpdater = () => {
837 if (!app.isPackaged) return;
838 autoUpdater.logger = log;
839 autoUpdater.autoDownload = true;
840 autoUpdater.autoInstallOnAppQuit = false;
841
842 autoUpdater.on("update-available", (info: UpdateInfo) => {
843 pendingUpdateVersion = info.version;
844 setUpdateStatus({ state: "available", version: info.version });
845 });
846 autoUpdater.on("download-progress", (progress: ProgressInfo) => {
847 if (pendingUpdateVersion) {
848 setUpdateStatus({
849 state: "downloading",
850 version: pendingUpdateVersion,
851 percent: Math.round(progress.percent ?? 0),
852 });
853 }
854 });
855 autoUpdater.on("update-downloaded", (info: UpdateInfo) => {
856 downloadedUpdateVersion = info.version;
857 setUpdateStatus({ state: "downloaded", version: info.version });
858 void promptInstallUpdate(info.version);
859 });
860 autoUpdater.on("error", (err: Error) => {
861 log.warn("[updater] error", err);
862 });
863
864 setInterval(() => {
865 if (downloadedUpdateVersion) return; // already staged; waiting on the user
866 void runUpdateCheck({ alertOnFail: false });
867 }, UPDATE_POLL_INTERVAL_MS);
868};
869
870interface UpdateCheckOptions {
871 readonly alertOnFail: boolean;

Callers 1

bootFunction · 0.85

Calls 4

setUpdateStatusFunction · 0.85
promptInstallUpdateFunction · 0.85
runUpdateCheckFunction · 0.85
warnMethod · 0.80

Tested by

no test coverage detected