fix(selfupdate): 下载重试续传 + 手动下载兜底 + 下载中隐藏按钮 - #4
Merged
Conversation
真机反馈:自更新下载很慢、第一次直接失败;下载中按钮看着还能点。根因与修复: download.py(慢/不稳链路优化,THS 安装下载同样受益): - 去掉"为读 Content-Length 多发一个完整 GET"的重复建连(慢链路上翻倍失败面) - 加自动重试 + 断点续传:单次失败保留半成品、下次带 Range 续传、指数退避; 超时改为 connect/sock_read(连不上快速失败、下载慢但有进展就耐心等),不设总时长封顶 apply.py: - 只在 SHA256 校验失败(数据不可信)时删 .new;下载/网络失败保留半成品, 让"重试更新"能续传而非从 0 重来(下次启动 cleanup_orphan_files 兜底清理) main_window.py: - 下载中隐藏全部按钮、只留进度条(Windows 上 disabled 按钮视觉太弱、看着仍可点) - 错误态新增「手动下载」按钮:浏览器打开新版 exe 直链,失败后不至于卡住 - 横幅控件改为按 状态/版本 变化才重排一次,避免每 100ms 重 pack 闪烁 测试:新增 download 重试成功、Range 续传两个用例;全量 91 passed / 10 skipped。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
suny911
marked this pull request as ready for review
July 4, 2026 10:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
v0.6.1 真机反馈:自更新下载很慢、第一次直接失败;下载中的按钮看着仍可点(Windows 控件 disabled 视觉太弱)。这是自更新器首次真机运行暴露的问题——横幅/进度都正常,卡在下载环节。
根因与修复
下载慢/失败 ——
installer/download.py(THS 安装下载同样受益)Content-Length,再发第二个 GET 才真正下载 → 慢/不稳链路上等于翻倍建连与失败面。改为单 GET。Range头续传、指数退避封顶 10s,只有重试全部耗尽才抛错。一次网络抖动不再等于整体失败。connect/sock_read(连不上快速失败、下载慢但有进展就耐心等)替代总时长封顶 —— 大文件慢下不再被总时长砍掉。续传能跨"重试"按钮 ——
selfupdate/apply.py.new;下载/网络失败保留.new,用户点「重试更新」可续传而非从 0 重来(下次启动cleanup_orphan_files兜底清理,不堆积)。按钮交互 ——
main_window.pywebbrowser.open打开新版 exe 直链(浏览器/下载工具通常更快更稳),失败后用户不至于卡住不知所措。测试
test_download_retries_then_succeeds(首次失败→重试成功)、test_download_resumes_with_range_header(带 Range 续传、拼接完整不覆盖)备注
此改动会随下一个版本(v0.6.2)带出。建议合并后正好用 v0.6.1→v0.6.2 这次升级,在 Windows 真机验证下载优化 + 手动下载兜底 + 按钮交互的真实效果(即 Task 6 的自然延续)。
🤖 Generated with Claude Code