Skip to content

fix(backend-p2p): move a directory with its contents, delete only empty - #107

Draft
Mearman wants to merge 1 commit into
mainfrom
fix/p2p-directory-move-delete
Draft

Mearman wants to merge 1 commit into
mainfrom
fix/p2p-directory-move-delete

Conversation

@Mearman

@Mearman Mearman commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

P2pBackend::move_entry wrote only the moved entry's own row, so moving a directory left every row under it at its old path, and delete tombstoned a directory while its children stayed live.

A directory now moves with all its live descendants inside the same write_atomically step, each as a new row plus a tombstone at the old path. A move onto a live entry is refused with Conflict when either side is a directory, and delete refuses a directory that still has live rows under it. That is the non-recursive Backend::delete contract that #100 writes down and that NFS RMDIR and cascade rm rely on; callers that mean a recursive delete get one from #100's vfs::transfer::delete_tree. Descendants are matched by exact path prefix rather than LIKE.

This was part of #100, but main has since rewritten delete and move_entry around write_atomically, so it is made against main here and #100 keeps only the P2P metadata change. The two branches merge with no conflict.

New tests moving_a_directory_moves_its_contents, moving_a_directory_onto_an_existing_entry_is_refused and deleting_a_non_empty_directory_is_refused all fail on main. cargo fmt --check, cargo clippy --workspace --all-targets -- -D warnings and cargo test --workspace pass.

Update 2026-12-01: parked in favour of #117

#100 is parked and its read-only mount fix is now #117, so this pull request, which completes #100's delete contract for P2P, stays a draft with it. Open problems in this change are #113 (a destination folder with no row of its own is not seen) and #114 (subfolders a peer creates under the old path, or that have no row, are left behind); the rest of the split is listed on #100.

move_entry wrote only the directory's own row, so every row under it
kept its old path, and delete tombstoned a directory while its
children stayed live. A directory now moves with all its live
descendants in the same atomic write, a destination that holds a live
entry is refused when either side is a directory, and delete refuses
a directory that still has live rows under it, as the Backend trait's
delete is non-recursive. Descendants are matched by exact path prefix.
Copilot AI balanced review requested due to automatic review settings December 1, 2026 12:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
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.

2 participants