Conversation
Offline clients re-uploaded files deleted while they were away because deletes only lived in memory. The ledger in .bh_filesync/deletion-ledger.json keeps tombstones across restarts so deletes survive reconnects.
Message::Delete now carries deleted_at_ms and deleter plus LedgerExchange so peers can compare delete time versus file mtime. Clean break, no compat shim.
apply_deletes now persists a tombstone even when the file is already absent, and filter_resurrected blocks re-upload when the remote tombstone is newer than local mtime. Legitimate recreates with newer mtime still win and clear the tombstone.
After ManifestExchange both peers swap LedgerExchange, merge with last-writer-wins, delete locally-resurrected files with the original stamp, and push deletes the offline peer missed. Live deletes preserve the sender timestamp on forward.
Covers the offline-delete-stays-deleted repro, recreate-wins, ledger persist/prune/TTL, corrupt-backup handling, and v8 wire roundtrips.
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 introduces significant improvements to the deletion and resurrection handling in the file synchronization protocol, ensuring that file deletions are robustly tracked and propagated between client and server. The changes implement a symmetric deletion-ledger exchange, improve tombstone handling to prevent unintended file resurrection, and update message formats and internal methods to support richer metadata for deletes. Some test code was also removed. The most important changes are:
Deletion Ledger Synchronization and Protocol Enhancements:
LedgerExchange), ensuring both sides have a consistent view of deleted files and preventing missed deletes from being overwritten. (crates/filesync/src/client.rs)Deletemessage to includedeleted_at_msanddeletermetadata, and updated all send/receive paths to use and handle this richer metadata, allowing precise tracking of when and by whom a file was deleted. (crates/filesync/src/client.rs,crates/filesync/src/common.rs) [1] [2] [3]Tombstone and Resurrection Handling:
crates/filesync/src/client.rs) [1] [2]crates/filesync/src/client.rs)Internal API and Code Cleanups:
PendingChanges::take_deletes_with_engineto ensure tombstones are recorded before sending deletes, and updated the flush path to use this method. (crates/filesync/src/common.rs,crates/filesync/src/client.rs) [1] [2]crates/filesync/src/client.rs)These changes greatly improve the safety and reliability of file deletion propagation, preventing data loss from missed deletes and ensuring proper conflict resolution in the presence of offline edits and file resurrection scenarios.