From fb77d9799dbca6ee510e518a5bc450807ae857dd Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Sat, 21 Nov 2026 02:55:36 +0800 Subject: [PATCH] =?UTF-8?q?fix(mcp):=20simulate=5Fcheck=5Fupdate=20?= =?UTF-8?q?=E7=9A=84=20manifest=5Furl=20=E7=BC=BA=20app=5Fkey?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit packageResult 读的是未预加载的 v.Application.AppKey,实际输出成 /api/v1/app//versions/manifest。改为由调用方显式传入 appKey。 --- backend/internal/router/mcp/helpers.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/internal/router/mcp/helpers.go b/backend/internal/router/mcp/helpers.go index 50ce1e7..17a699d 100644 --- a/backend/internal/router/mcp/helpers.go +++ b/backend/internal/router/mcp/helpers.go @@ -70,7 +70,7 @@ func simulateCheckUpdate(appKey, clientVersion string) (gin.H, error) { // 安装器模式:客户端没报版本号,直接给最新全量包 if strings.TrimSpace(clientVersion) == "" { lv := &published[0] - res := packageResult(lv, clientVersion) + res := packageResult(lv, a.AppKey, clientVersion) res["mode"] = "installer_mode(未上报版本号 → 直接下发最新包)" res["has_update"] = true mergeH(base, res) @@ -95,7 +95,7 @@ func simulateCheckUpdate(appKey, clientVersion string) (gin.H, error) { // 客户端版本号在服务器里匹配不到 → 整包兜底(新代码行为) if cur == nil { lv := &published[0] - res := packageResult(lv, clientVersion) + res := packageResult(lv, a.AppKey, clientVersion) res["mode"] = "unknown_client_version(客户端版本号在服务器不存在 → 下发最新整包)" res["has_update"] = true mergeH(base, res) @@ -141,7 +141,7 @@ func simulateCheckUpdate(appKey, clientVersion string) (gin.H, error) { return nil, fmt.Errorf("读取最新版本失败: %w", err) } - res := packageResult(&lvFull, clientVersion) + res := packageResult(&lvFull, a.AppKey, clientVersion) res["has_update"] = true res["update_strategy"] = strategy res["mode"] = "update" @@ -154,7 +154,7 @@ func simulateCheckUpdate(appKey, clientVersion string) (gin.H, error) { } // packageResult 按 handler 的优先级给出下载地址、hash、清单信息 -func packageResult(v *model.Version, clientVersion string) gin.H { +func packageResult(v *model.Version, appKey, clientVersion string) gin.H { downloadURL := v.FullPackagePath downloadSize := v.FullPackageSize downloadHash := v.FullPackageHash @@ -194,7 +194,7 @@ func packageResult(v *model.Version, clientVersion string) gin.H { "patch_size": v.FileSize, "patch_hash": v.FileHash, "is_patch_delivery": isPatch, - "manifest_url": fmt.Sprintf("/api/v1/app/%s/versions/manifest?version_id=%d", v.Application.AppKey, v.ID), + "manifest_url": fmt.Sprintf("/api/v1/app/%s/versions/manifest?version_id=%d", appKey, v.ID), "manifest_hash": manifestHash, "manifest_complete": complete, "manifest_content_read": stored,