How I made file moves between drives undoable and verified in a Rust desktop app
说明与用途
Rust 桌面应用程序确保跨驱动器的文件移动是原子、可验证且可撤销的,防止文件部分复制和意外删除。
问题
Moving movie files across multiple drives often left half‑finished copies and no way to undo the operation.
结果
The application now guarantees that file moves are atomic, verifiable, and reversible, eliminating half‑finished copies and accidental deletions.
工作流
- 1. Write every planned move step to a SQLite journal before touching the disk.
- 2. Perform a pipelined copy using a reader/writer, flush buffers, read back past the OS cache, and compare SHA‑256 checksums.
- 3. Move the original files to the recycle bin/freedesktop trash using rename only, never copying.
- 4. Stage the new location in a temporary folder, then rename once the copy is verified.
- 5. Update the library to point to the new location.
- 6. Provide an undo feature that reverts moves based on the journal history.
- 7. Handle crashes mid‑move by replaying or rolling back journal entries.
证据
the problem: my movie library on several drives, moves that half-finish, no undo
journal first: write every planned step to SQLite before touching the disk
the copy: pipelined reader/writer, flush, read back past the OS cache, compare SHA-256
originals to the recycle bin / freedesktop trash (rename-only, never copied)
- 记录日期: 2026-11-01T05:13:55.685Z