fix(filelib): 恢复撞名不再死锁,自动改名「(已恢复)」(ADR-0033)

- restore 前查活跃兄弟:撞名则恢复为「原名(已恢复[/ N])」(截断计入
  128 长度预算),同事务落审计并记 renamedFrom;API 返回最终名
- BinView toast 提示改名;测试补撞名/二次恢复用例
This commit is contained in:
ymy
2026-07-31 13:52:23 +08:00
parent f99c8ea4d8
commit 9e38d1e011
5 changed files with 107 additions and 12 deletions
+9 -2
View File
@@ -36,8 +36,15 @@
async function restore(e: BinEntry): Promise<void> {
busyId = e.id;
try {
await api(`/database/api/bin/${encodeURIComponent(e.id)}/restore`, { method: "POST" });
toastOk(`已恢复「${e.name}`);
const r = await api<{ name: string; renamedFrom?: string }>(
`/database/api/bin/${encodeURIComponent(e.id)}/restore`,
{ method: "POST" },
);
toastOk(
r.renamedFrom !== undefined && r.renamedFrom !== r.name
? `已恢复为「${r.name}」(原名与现有节点冲突)`
: `已恢复「${r.name}」`,
);
await load();
} catch (err) {
toastErr(err instanceof Error ? err.message : String(err));