automerge/automerge-repo

Delete protocol

acurrieclark opened this issue · 1 comments

When we delete a document from a local repo, all it does set the local handle to a deleted state, emit an event and remove from local storage.

While there is a test to ensure that a deleted document can be refetched, I don't think this works as expected. For example, while we remove the local handle from the cache, we don't delete the local synchronizer, nor do we inform the network that we have have deleted the document.

I would suggest that we should remove the local synchronizer and probably inform the network of the deletion. Relevant peers should then remove the peer from their list of peers to synchronize with. This is if particular relevance to a sync server, which would otherwise look to continue syncing changes it receives from elsewhere.

At some point we should add a hook which a peer can use to determine if there is anything else which should be done with a delete message. For example, if you deleted in one tab, you might want to delete in a service worker and all other tabs but just stop syncing from your sync server.

Also worth writing a test to check that if a document (which has not previously been synched with another peer) has been deleted, that it cannot be requested by another peer.