Skip to content

Commit f1f280a

Browse files
JusterZhuclaude
andauthored
fix(Server): AppType filtering, WebRootPath, and new patch package (#43)
* fix(Server): AppType filtering, WebRootPath, and new patch package - Use IWebHostEnvironment.WebRootPath instead of AppDomain.BaseDirectory to correctly locate wwwroot in both dev and publish scenarios - Filter patches by request.AppType to avoid returning mismatched updates - Remove hardcoded call counter to allow repeated test runs - Add patch_20260529221936.zip with matching SHA256 hash - Update csproj to copy patch_*.zip to output directory * feat(Server): 完善升级服务器,支持全量/差分升级包 ISSUE: src/Server 仅是一个硬编码模拟服务器,不支持: - versions.json 动态加载 - AppType/Platform/ProductId 过滤 - VersionChain / CrossVersion 升级模式 - 基于 SHA256 的文件下载(断点续传) - ClientTest/UpgradeTest 端到端升级流程 CHANGES: Server: 重写 Program.cs,从 versions.json 动态加载包元数据 新增 /Upgrade/ 和 /Update/ 双路由兼容 新增 GET /File/Download/{hash} 下载端点(支持 Range) 新增请求日志中间件 新增 8 个升级包(Client/Upgrade × 全量/差分 × 多版本) DTOs: VerifyDTO 新增 UpgradeMode 字段 VerificationResultDTO 新增 UrlExpireTimeUtc/UpgradeMode/ IsCrossVersion/FromVersion/ToVersion 字段 脚本: generate_packages.ps1 — 从 content 目录生成升级包 finalize_packages.ps1 — 整合差分/模拟包并生成 versions.json create_versions_json.ps1 — 重建 versions.json Content: 从 content_client/content_upgrade 移除 GeneralUpdate.*.dll, 避免升级包覆盖运行时 DLL 导致 IPC 解密失败 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 5ffa4e1 commit f1f280a

10 files changed

Lines changed: 750 additions & 83 deletions

src/Server/DTOs/VerificationResultDTO.cs

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ namespace ServerSample.DTOs;
33
public record VerificationResultDTO
44
{
55
/// <summary>
6-
/// 用于更新结果上报
6+
/// 记录 ID,用于更新结果上报
77
/// </summary>
88
public int RecordId { get; set; }
9-
9+
1010
/// <summary>
1111
/// 包名称
1212
/// </summary>
1313
public string? Name { get; set; }
1414

1515
/// <summary>
16-
/// 补丁包hash值
16+
/// 补丁包 SHA256 哈希值
1717
/// </summary>
1818
public string? Hash { get; set; }
1919

@@ -27,40 +27,68 @@ public record VerificationResultDTO
2727
/// </summary>
2828
public string? Url { get; set; }
2929

30+
/// <summary>
31+
/// 签名 URL 过期时间 (UTC)
32+
/// </summary>
33+
public DateTime? UrlExpireTimeUtc { get; set; }
34+
3035
/// <summary>
3136
/// 版本号
3237
/// </summary>
3338
public string? Version { get; set; }
3439

3540
/// <summary>
36-
/// 应用类型
41+
/// 应用类型: 1=Client(主应用), 2=Upgrade(升级器)
3742
/// </summary>
3843
public int? AppType { get; set; }
3944

4045
/// <summary>
41-
/// 平台
46+
/// 系统平台: 1=Windows, 2=Linux, 3=macOS
4247
/// </summary>
4348
public int? Platform { get; set; }
4449

4550
/// <summary>
46-
/// 产品id
51+
/// 产品 ID
4752
/// </summary>
4853
public string? ProductId { get; set; }
4954

5055
/// <summary>
5156
/// 是否强制更新
5257
/// </summary>
5358
public bool? IsForcibly { get; set; }
54-
59+
5560
/// <summary>
56-
/// 文件格式
61+
/// 文件格式(如 .zip)
5762
/// </summary>
58-
public string Format { get; set; } = string.Empty;
63+
public string? Format { get; set; }
5964

6065
/// <summary>
61-
/// 文件大小
66+
/// 文件大小(字节)
6267
/// </summary>
6368
public long? Size { get; set; }
64-
69+
70+
/// <summary>
71+
/// 是否冻结(冻结的包不参与更新)
72+
/// </summary>
6573
public bool? IsFreeze { get; set; }
74+
75+
/// <summary>
76+
/// 升级模式: 1=VersionChain, 2=CrossVersion
77+
/// </summary>
78+
public int? UpgradeMode { get; set; }
79+
80+
/// <summary>
81+
/// 是否为跨版本升级包
82+
/// </summary>
83+
public bool? IsCrossVersion { get; set; }
84+
85+
/// <summary>
86+
/// 跨版本升级的源版本号
87+
/// </summary>
88+
public string? FromVersion { get; set; }
89+
90+
/// <summary>
91+
/// 跨版本升级的目标版本号
92+
/// </summary>
93+
public string? ToVersion { get; set; }
6694
}

src/Server/DTOs/VerifyDTO.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,32 @@ namespace ServerSample.DTOs;
33
public class VerifyDTO
44
{
55
/// <summary>
6-
/// 版本号
6+
/// 客户端当前版本号
77
/// </summary>
88
public string? Version { get; set; }
99

1010
/// <summary>
11-
/// 应用类型
11+
/// 应用类型: 1=Client(主应用), 2=Upgrade(升级器)
1212
/// </summary>
1313
public int? AppType { get; set; }
1414

1515
/// <summary>
16-
/// 应用密钥
16+
/// 应用密钥,用于服务端验证
1717
/// </summary>
1818
public string? AppKey { get; set; }
1919

2020
/// <summary>
21-
/// 系统平台
21+
/// 系统平台: 1=Windows, 2=Linux, 3=macOS
2222
/// </summary>
2323
public int? Platform { get; set; }
2424

2525
/// <summary>
26-
/// 所属产品分支id
26+
/// 所属产品分支 ID
2727
/// </summary>
2828
public string? ProductId { get; set; }
29+
30+
/// <summary>
31+
/// 升级模式: 1=VersionChain(逐版本链式升级), 2=CrossVersion(跨版本升级)
32+
/// </summary>
33+
public int? UpgradeMode { get; set; }
2934
}

0 commit comments

Comments
 (0)