Conversation
Dir deletes tombstone only the top path, so children resurrected via exact-match checks. Add nearest-ancestor lookup plus has_newer_than_prefix so a parent delete covers stale children while newer-mtime recreates still win.
filter_resurrected only checked exact paths, so files under a deleted dir were re-uploaded as new. Fall back to ancestor tombstones for children (timestamp-only) while keeping hash/mtime checks for exact paths, so stale subtrees stay deleted and legitimate recreates win.
Moved-in subtrees stayed unwatched and wd->path entries kept pointing at the old location, so events inside a moved dir were mis-attributed to the old path and recreated phantom folders. Recursively watch CREATE/MOVED_TO dirs, rewrite wd_map prefixes on rename, drop stale watches on IGNORED/MOVE_SELF/DELETE_SELF, and extend move pairing to 2s.
apply_rename moved only the top manifest entry, leaving children on the old path so scans recreated the source dir. Remap the full subtree component-wise, suppress all remapped keys, and make missing-src with present-dst converge instead of erroring. Veto bundle/large-file writes covered by a newer tombstone, lift tombstones on newer-mtime recreates, and clear prefix tombstones on trash restore. Document why Rename keeps no move_id for bincode compat.
Flushes stamped ledger and wire deletes with two now_ms calls so peers disagreed on LWW winners. Reuse one batch stamp, propagate sender stamps on forward, prune fabricated ancestor deletes, suppress rename subtrees recursively, and veto outgoing paths covered by a newer tombstone before streaming or broadcasting.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request significantly strengthens the handling of file and directory deletions (tombstones) and resurrection protection in the file sync engine, ensuring that deleted directories correctly prevent stale or unintended child files from being resurrected. The changes introduce a "covering tombstone" concept, improve the logic for filtering out stale files on both client and server, and add robust tests to guarantee correctness. Additionally, the restoration process from trash now properly clears covering tombstones to allow legitimate restores.
Tombstone Handling and Resurrection Protection:
DeletionLedger, allowing the system to detect when a file or directory (or any ancestor) has been deleted and to veto uploads or downloads of stale children accordingly. (covering_tombstoneandhas_newer_than_prefixmethods, plus extensive tests) [1] [2]send_paths_to_server,broadcast_paths) to filter out files and directories that are covered by a newer tombstone, logging vetoes and preventing resurrection of deleted content. [1] [2]handle_recv_bundle) to defensively filter out files covered by tombstones before applying changes, preventing stale retransmissions from resurrecting deleted files.Protocol and Manifest Logic Improvements:
filter_resurrectedand its documentation to handle both exact and covering tombstones, ensuring correct behavior for directory deletes and their children. Added comprehensive tests for these scenarios. [1] [2] [3] [4]Restore and Trash Handling:
restore_trash_entryto clear all tombstones covering the restored path, ensuring that legitimate restores are not immediately vetoed by prior deletes.These changes collectively make the sync engine more robust against accidental resurrection of deleted files and directories, and ensure that legitimate recreations and restores work as expected.