fix: 中断时恢复旧控制面板#5224
Open
eyaeya wants to merge 1 commit into
Open
Conversation
Closed
Contributor
Author
2026-07-08 最新上游覆盖复核与范围收窄本轮按最新 执行计划与本次更新:
已推送:
验证: bash -n luci-app-openclash/root/usr/share/openclash/*.sh
bash -n tests/openclash_download_dashboard_test.sh
bash tests/openclash_download_dashboard_test.sh
git diff --check origin/dev...HEAD
rg -n '^(<<<<<<<|=======|>>>>>>>)' luci-app-openclash/root/usr/share/openclash/openclash_download_dashboard.sh tests/openclash_download_dashboard_test.sh以上均通过。未做 live router 写入验证;本轮只做静态与聚焦脚本验证。 |
2e3cbfe to
1240c47
Compare
Contributor
Author
|
补充读回:分支 head 后续更新为 |
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 基于已合入的 #5193。#5193 已解决 dashboard 下载校验、staging 安装和失败回滚;本 PR 只补信号中断窗口。
问题现象
控制面板更新时,如果进程在旧目录已移动到
.openclash_dashboard_old.$$、新目录尚未完成落位和校验之间收到HUP/INT/TERM,目标 dashboard 目录可能暂时或永久缺失,只留下隐藏旧目录或 staging 目录。根因
#5193 的普通失败路径会调用
restore_old_dashboard,但脚本没有 signal trap。外部中断不会走普通错误分支,因而不会恢复旧 dashboard 或清理 staging 目录。证据
openclash_download_dashboard.sh先把现有TARGET_FILE_DIR移到.openclash_dashboard_old.$$,随后再把.openclash_dashboard_new.$$移回目标目录。HUP/INT/TERM不会进入该路径。mvwrapper 在旧目录移动成功后发送TERM,验证脚本返回中断状态、旧index.html被恢复、.openclash_dashboard_*staging 目录被清理。修复方案
DASHBOARD_REPLACE_STARTED标志,只在旧目录替换窗口开启后允许恢复旧 dashboard。HUP/INT/TERM增加 trap:恢复旧目录、清理临时文件、释放锁并退出。为什么没有扩大修复范围
没有修改 #5193 已合入的目录完整性校验、304 复验、staging 路径或下载逻辑。trap 早于替换窗口不会删除目标目录;只有确认旧目录已进入
.old.$$窗口后才尝试恢复。与已有开启态 PR 的关系
nat_output等路径,不覆盖本问题。验证命令和结果
均已通过:
最后一条无命中。
剩余风险
未做 live router 验证。该补丁只处理脚本进程收到常见终止信号的情况;断电、内核级强制 kill 等无法由 shell trap 恢复。