Skip to content

fix(Server): AppType filtering, WebRootPath, and new patch package#43

Merged
JusterZhu merged 2 commits into
mainfrom
redesign-samples
May 31, 2026
Merged

fix(Server): AppType filtering, WebRootPath, and new patch package#43
JusterZhu merged 2 commits into
mainfrom
redesign-samples

Conversation

@JusterZhu

@JusterZhu JusterZhu commented May 29, 2026

Copy link
Copy Markdown
Collaborator

重写 src/Server,从硬编码模拟升级为功能完善的升级服务器。

Closes #44

Changes

Server 重写

  • versions.json 动态加载包元数据(自动计算 hash/size)
  • 按 version > 当前版本 / appType / platform / productId 过滤
  • 支持 VersionChain(全量)和 CrossVersion(差分)升级模式
  • 新增 GET /File/Download/{hash} 下载端点(HTTP Range 断点续传)
  • /Upgrade/ 和 /Update/ 双路由兼容

DTOs 补全

  • VerifyDTO 新增 UpgradeMode
  • VerificationResultDTO 新增 5 个缺失字段

升级包

  • Client/Upgrade × 全量/差分 × 多版本(共 8 个)
  • 移除包内 GeneralUpdate.*.dll,避免 IPC 解密失败

脚本

  • generate_packages.ps1 / finalize_packages.ps1 / create_versions_json.ps1

- 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
Copilot AI review requested due to automatic review settings May 29, 2026 17:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the sample server to correctly locate packages via IWebHostEnvironment.WebRootPath, filter returned patches by the request's AppType, and ship a freshly built patch package (with matching SHA256) so the sample can be re-run without the previous hardcoded call-count guard.

Changes:

  • Replace AppDomain.CurrentDomain.BaseDirectory with IWebHostEnvironment.WebRootPath and remove the call counter gating repeated runs.
  • Add AppType matching on incoming VerifyDTO requests and update the served package metadata (name/hash/URL/AppType).
  • Update csproj to copy any patch_*.zip to output and refresh versions.json to reference the new patch package.

Reviewed changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 1 comment.

File Description
src/Server/Program.cs Switches to WebRootPath, removes call counter, adds AppType filtering, updates package name/hash/AppType.
src/Server/ServerSample.csproj Replaces specific zip Content entry with patch_*.zip glob and removes duplicate None Include entry.
src/Server/wwwroot/packages/versions.json Points to the new patch_20260529221936 package with its new hash and URL.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Server/Program.cs Outdated
Comment on lines +24 to +27
// Only return patches whose AppType matches the request.
// Client convention: Client=1, Upgrade=2 (matches GeneralUpdate.Core.AppType enum).
// This patch is a main application update (AppType=Client).
const int patchAppType = 2; // Client
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>
@JusterZhu JusterZhu merged commit f1f280a into main May 31, 2026
1 check passed
@JusterZhu JusterZhu deleted the redesign-samples branch June 3, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: 完善升级服务器,支持 ClientTest/UpgradeTest 端到端升级

2 participants