Skip to content

fix(gpui): 写入日志与中断写入的启动恢复 - #91

Merged
yeagoo merged 3 commits into
mainfrom
fix/gpui-write-journal
Oct 24, 2026
Merged

yeagoo merged 3 commits into
mainfrom
fix/gpui-write-journal

Conversation

@yeagoo

@yeagoo yeagoo commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

实现 docs/GPUI_MACOS_LIFECYCLE_PLAN.md 的 PR-B(L5)。

问题

强退、崩溃或退出等待超时后,输出目录会留下隐藏的 .imgconvert-*.tmp;在需要先暂存旧输出的平台(主要是 Windows),中断还可能让用户原来的输出只剩 imgconvert-backup-* 名称。

修复

  • 新增 imgconvert-backend::write_journal:在创建临时文件、暂存旧输出之前,把路径写入应用数据目录下 pending-writes/ 的日志并落盘;写入结束追加结束记录。从不扫描用户文件夹,只处理日志点名的路径。
  • GPUI 启动时(持有单实例标记后、任何转换前)恢复:新输出未就位则把备份改回原名;新输出已就位则删除备份;删除日志点名且符合生成名规则的普通临时文件;无法判断、无法访问、文件夹不存在(如未挂载)的条目保留到下次。
  • 失败即保守:日志记录失败时不暂存原输出;中间损坏的日志改名保留;跨日志的操作 id 唯一,不会合并。
  • 选择输出文件夹后重试保留条目(Mac App Store 沙盒重新授权)。
  • Tauri 壳不安装日志,行为不变。

验证

  • 后端测试 222 项通过(新增 11 项:名称规则、临时文件清理、备份恢复/删除、模糊状态保留、损坏行、未挂载文件夹、损坏日志、跨日志 id、重试排除自身日志、真实写入路径的日志与结束记录);GPUI 全部测试与 clippy 通过。
  • macOS 13.6 虚拟机:用构造的上次未完成日志启动,备份恢复为原输出、日志点名的临时文件被删除、未点名的临时文件保持不动。
  • Codex 评审:8 项意见均已处理(见方案第 7 节),修正后复核见下方评论。

🤖 Generated with Claude Code

yeagoo and others added 3 commits October 25, 2026 02:27
A forced quit, crash or shutdown timeout could leave hidden temporary
outputs behind and, on Windows, the previous output only under its backup
name. Each write now records its temporary and backup paths in a synced
journal in the application data directory before creating them; at
startup, while holding the instance marker, the shell restores a staged
backup whose new output never arrived, removes leftover temporaries that
match the generated names, and carries anything it cannot resolve forward.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ries

Op ids are unique across journals so carried records never merge; a backup
is never staged when its journal record cannot be written; entries whose
folder cannot be inspected are kept instead of treated as done; a journal
damaged before its last line is kept as *.unreadable; the end of a staged
write is synced; recovery is retried after an output folder is granted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yeagoo
yeagoo merged commit 6cc0736 into main Oct 24, 2026
10 checks passed
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.

1 participant