fix: 拒绝复用失败的版本状态 - #5222
Closed
eyaeya wants to merge 1 commit into
Closed
fix: 拒绝复用失败的版本状态#5222eyaeya wants to merge 1 commit into
eyaeya wants to merge 1 commit into
Conversation
This was referenced Jul 8, 2026
Closed
Closed
Closed
Contributor
Author
|
这个拆分 PR 已被新的合并版 PR 取代:#5231 原因:#5217、#5218、#5222 都属于更新/版本状态健壮性修复,并且按任意顺序合并时会在 已在合并版 PR 中验证:
|
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.
Dependency chain
推荐合并顺序:本 PR 可独立合并;若同时处理系统包管理器锁状态,请优先或并行合并 #5217。两者触及相邻更新路径,但行为边界不同。
问题现象
核心版本检测或 OpenClash 包版本检测失败时,旧的
/tmp/clash_last_version、/tmp/openclash_last_version仍会留在本机。随后openclash_core.sh和openclash_update.sh只看固定版本文件是否存在,可能把旧版本状态当成本轮检测结果继续进入更新判断。根因
clash_version.sh和openclash_version.sh调用DOWNLOAD_FILE_CURL后没有检查返回码,也没有在失败时清理旧版本状态文件。调用方也只判断 fixed last_version 文件是否存在,没有区分“本轮检测成功”和“旧文件还在”。证据
clash_version.sh原先直接调用DOWNLOAD_FILE_CURL "$DOWNLOAD_URL" "$DOWNLOAD_FILE" "$DOWNLOAD_FILE"后释放锁并退出。openclash_version.sh原先只在$? -eq 0时处理版本内容,失败时旧/tmp/openclash_last_version仍保留。openclash_core.sh原先只判断/tmp/clash_last_version是否存在。openclash_update.sh原先只判断/tmp/openclash_last_version是否存在。tests/openclash_version_state_test.sh覆盖了“已有旧版本文件 + 本轮下载失败”的场景,并验证调用方在版本刷新失败后不会继续进入后续下载路径。修复方案
DOWNLOAD_FILE_CURL返回码。0或2时按现有成功/304 缓存语义继续。openclash_core.sh、openclash_update.sh同时检查版本脚本退出码和 last_version 文件存在性。为什么没有扩大修复范围
没有修改
openclash_curl.sh的通用下载实现,因为它已经使用.download.$$临时文件避免半截下载覆盖目标。本 PR 只修复调用方对“失败但旧状态仍存在”的判断问题,不改变 ETag、304、CDN、release asset 或系统 feed 行为。与已有开启态 PR 的关系
验证命令和结果
均已通过:
最后一条无命中。
剩余风险
未做 live router 验证。该修复只改变版本检测失败后的状态处理;如果网络临时失败,UI/更新脚本会要求重新检测版本,而不是继续复用旧 last_version。