fix: 收口批次D并修复本地垃圾箱清空

This commit is contained in:
lix-2026
2026-05-21 15:45:11 +08:00
parent e709c0705c
commit dc18ec0a60
14 changed files with 525 additions and 72 deletions
@@ -0,0 +1,19 @@
# 4-48 [done] 本地文件夹页面垃圾箱清空改为串行 purge v1
> 状态:DONE
>
> 日期:2026-05-21
>
> 问题:
> 清空页面垃圾箱时,多个页面条目会并发触发 `purge`,导致本地元数据写入竞争,后台出现 `无法替换本地元数据 ... file-order.json: No such file or directory`。
>
> 根因:
> `gateway.rs` 里的 local trash 清空逻辑使用 `Promise.all(rows.map(...))` 并发调用 `/api/tree/commands`,多个页面条目同时写同一个 `.mnote/file-order.json`。
>
> 修复:
> 改为串行 `rows.reduce(...).then(...)`,按顺序依次 purge 页面条目,避免并发写元数据。
>
> 验证:
> - `cargo test -p mnote-web trash_entry_renders_local_folder_trash_workbench -- --test-threads=1`
> - `node scripts/task474-local-folder-empty-trash-ui-smoke.js`
> - 重新扩充 task474 为两个页面条目后,清空页面垃圾箱通过,`trash-index` 最终为空,`navDelta=0`