Repository navigation
fix(core): cache clear --web 保留运行中的 serve 显示的网页版本 - #1145
Merged
Merged
Conversation
cache clear --web(以及 --all、WebUI 设置里清理「网页版本」)原来整个删除 cache/web, 连运行中的 serve 用 hold() 持有的版本也删掉,/ui/ 立即变成 404。现在逐个版本经 WebStore::remove 删除:被持有的版本连同它的锁文件和指向它的 current 保留,并在 warnings 里说明;进程已不在的下载目录、没有版本的锁文件、指向已删版本的 current 一并清掉。cache list 和 --dry-run 的 web 部分只列出会删掉的条目。 fixed #1139 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
问题
weflow cache clear --web(以及--all、WebUI「设置 → 缓存的文件 → 网页版本 → 清理」)把整个cache/web/删掉,连运行中的weflow serve用WebStore::hold持有的版本也删了,/ui/立即变成 404「网页中没有这个文件」。web prune和serve-files(#815)都有这层保护,只有这里漏了。做了什么
crates/weflow-core/src/webui/clear.rs(webui的子模块):WebStore::clear:先逐个版本调用WebStore::remove(在独占锁下删除),返回in_use的版本保留,并在warnings里写「WebUI X is shown by a runningweflow serve; it was kept」(中文:「网页 X 正由运行中的weflow serve显示,已保留」);再清理版本以外的条目:进程已不在的.download-*和.current-<pid>、没有对应版本且没人持有的.lock-*/.install-*、不指向保留版本的current、其他早期遗留的文件。被保留的版本是current时,current也保留。WebStore::clearable:不加锁地列出clear会删的条目;WebStore::is_held:版本是否被运行中的 serve 显示。services/cleanup.rs:cache_part_paths(CachePart::Web)改为clearable(),所以cache list和cache clear --dry-run(WebUI 确认框用的RemovalPlan)的 web 部分只列出会删掉的条目、大小也只算这些;cache_clear对 web 部分调用WebStore::clear,freedBytes按清理前后的实际差值计算。--web的帮助文字、CachePart::Web的文档注释(契约快照web/contract/openapi.json随之重写;生成的contract.gen.ts没有变化)、中文帮助和报错目录(help_zh.rs、messages_zh.rs各一行)。用户可见的变化
serve在运行时,清理网页版本不再删掉它正在显示的版本(和它的选定),结果里多一条警告说明保留了哪个版本;/ui/照常可用。没有 serve 运行时,所有版本照旧全部删除。cache list的web部分不再是cache/web这一个路径,而是会被清理的各个条目;正在显示的版本不计入大小,只剩它时 WebUI 的「清理」按钮不可点。验证
webui::clear::tests:条目按名字分类;hold 一个版本后clearable/clear保留它和current,删掉其他版本、陈旧的下载和锁、遗留文件,警告正确;放开后全部删除;正在运行的进程写的下载、.current-<pid>和正在安装时持有的.install-*保留。native_e2e::cache_clear_leaves_the_webui_version_a_server_shows:hold之后cache_list只列出另一个版本,cache_clear(&[Web])的removedPaths、freedBytes、warnings正确。web_versions::cache_clear_leaves_the_version_a_server_shows:对运行中的 serve 发DELETE /cache/clear?web=true&dry-run=true和…&yes=true,确认框不列出正在显示的版本,清理后/ui/仍是 200、选定仍在;停掉 serve 后cache clear --web全部删除。cargo fmt --all -- --check、cargo clippy -p weflow-core -p weflow-cli --all-targets -- -D warnings、cargo test -p weflow-core、cargo test -p weflow-cli、WEFLOW_UPDATE_CONTRACT=1 cargo test -p weflow-cli --bin weflow contract_、web/下bun run check全部通过。只用合成数据,未碰真实账号。fixed #1139
🤖 Generated with Claude Code