Skip to content

fix(update): 清理旧备份时不遍历目录链接 - #441

Open
MistEO wants to merge 1 commit into
mainfrom
codex/update-cleanup-link-boundaries
Open

MistEO wants to merge 1 commit into
mainfrom
codex/update-cleanup-link-boundaries

Conversation

@MistEO

@MistEO MistEO commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

清理更新备份时,原来的递归通过 Path::is_dir 跟随目录链接。旧目录内存在 Windows junction 或目录符号链接时,清理可能进入链接目标并删除其中的用户数据。

现在在递归入口读取不跟随链接的元数据,Windows 同时识别目录重解析点,只解除链接。保留逐项继续清理:遇到占用文件、枚举或元数据错误会累计失败并继续处理兄弟项。成功删除目录现在也纳入日志计数;两个调用方均只记录计数。

两轮独立 review 通过。5 项新增测试覆盖正常嵌套目录、嵌套和根 junction、悬空链接,以及独占打开文件后继续清理兄弟项。Windows 实际 junction 和独占文件验证通过;Unix 符号链接路径已静态审查,本地未执行。

验证:Windows 完整 crate 的 Cargo lib-test 编译通过。原测试 exe 因现有 Common Controls v6 manifest 缺失而在加载阶段退出;给该编译产物的副本嵌入 Tauri 默认 manifest 后,cleanup_ 过滤命中的 6 项测试全部通过(5 项新增、1 项既有)。rustfmt 和 git diff --check 通过。

基于 main c321532。本次没有更改调用方原有的 exists 检查,也不处理元数据检查与遍历之间的并发链接替换。

Sourcery 摘要

使 update-backup 清理能够安全地处理目录链接,同时继续尽力删除,并准确报告结果。

错误修复:

  • 防止 update-backup 清理遍历目录符号链接或 Windows 目录联接点;仅删除链接本身,保护链接指向的用户数据。
  • 在单个条目的枚举、元数据读取或删除失败后,继续清理同级条目,同时报告累计失败情况。

增强功能:

  • 将成功删除的目录计入清理数量,并在两个调用位置保留仅记录数量的日志。

测试:

  • 添加对嵌套清理、嵌套和根目录链接、失效链接,以及 Windows 文件被独占打开后仍继续清理的覆盖。
Original summary in English

Summary by Sourcery

Make update-backup cleanup safe for directory links while continuing best-effort removal and accurately reporting results.

Bug Fixes:

  • Prevent update-backup cleanup from traversing directory symlinks or Windows junctions, deleting only the link itself and protecting linked user data.
  • Continue cleaning sibling entries after individual enumeration, metadata, or deletion failures while reporting accumulated failures.

Enhancements:

  • Include successfully removed directories in cleanup counts and retain count-only logging at both call sites.

Tests:

  • Add coverage for nested cleanup, nested and root directory links, dangling links, and continued cleanup after an exclusively open Windows file.

AI 使用信息:

  • 实现、内部审查:Agent 为 Codex;模型为 gpt-6-astra;思考强度为 ultra。内部子代理继承父任务配置。
  • 审计交叉审查:Agent 为 Codex;模型为 gpt-6.1-sol;思考强度为 max(协调调用选定)。

@MistEO
MistEO marked this pull request as ready for review November 11, 2026 02:37
Copilot AI balanced review requested due to automatic review settings November 11, 2026 02:37
@sourcery-ai

sourcery-ai Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Sorry @MistEO, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 7 hours and 39 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T02:39:13.629953Z 6263b4f Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

2 participants