MCPcopy Create free account
hub / github.com/MemTensor/MemOS / handleUpdateCheck

Method handleUpdateCheck

packages/memos-core/src/viewer/server.ts:3637–3679  ·  view source on GitHub ↗
(res: http.ServerResponse)

Source from the content-addressed store, hash-verified

3635 }
3636
3637 private async handleUpdateCheck(res: http.ServerResponse): Promise<void> {
3638 const sendNoStore = (data: unknown, statusCode = 200) => {
3639 res.writeHead(statusCode, {
3640 "Content-Type": "application/json; charset=utf-8",
3641 "Cache-Control": "no-store, no-cache, must-revalidate, max-age=0",
3642 "Pragma": "no-cache",
3643 "Expires": "0",
3644 });
3645 res.end(JSON.stringify(data));
3646 };
3647 try {
3648 const pkgPath = this.findPluginPackageJson();
3649 if (!pkgPath) {
3650 sendNoStore({ updateAvailable: false, error: "package.json not found" });
3651 return;
3652 }
3653 const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
3654 const current = pkg.version as string;
3655 const name = pkg.name as string;
3656 if (!current || !name) {
3657 sendNoStore({ updateAvailable: false, current });
3658 return;
3659 }
3660 const { computeUpdateCheck } = await import("../update-check");
3661 const result = await computeUpdateCheck(name, current, fetch, 6_000);
3662 if (!result) {
3663 sendNoStore({ updateAvailable: false, current, packageName: name });
3664 return;
3665 }
3666 sendNoStore({
3667 updateAvailable: result.updateAvailable,
3668 current: result.current,
3669 latest: result.latest,
3670 packageName: result.packageName,
3671 channel: result.channel,
3672 installCommand: result.installCommand,
3673 stableChannel: result.stableChannel,
3674 });
3675 } catch (e) {
3676 this.log.warn(`handleUpdateCheck error: ${e}`);
3677 sendNoStore({ updateAvailable: false, error: String(e) });
3678 }
3679 }
3680
3681 private handleUpdateInstall(req: http.IncomingMessage, res: http.ServerResponse): void {
3682 let body = "";

Callers 1

handleRequestMethod · 0.95

Calls 4

findPluginPackageJsonMethod · 0.95
warnMethod · 0.65
computeUpdateCheckFunction · 0.50
parseMethod · 0.45

Tested by

no test coverage detected