fix(mcp): simulate_check_update 的 manifest_url 缺 app_key
packageResult 读的是未预加载的 v.Application.AppKey,实际输出成 /api/v1/app//versions/manifest。改为由调用方显式传入 appKey。
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user