Ensure worktree updates are observed in order on the server

This commit is contained in:
Antonio Scandurra
2022-02-16 14:05:10 +01:00
parent 3f6feb1c12
commit c3ba8f59ed
4 changed files with 19 additions and 8 deletions
+6
View File
@@ -537,6 +537,7 @@ impl Store {
connection_id: ConnectionId,
project_id: u64,
worktree_id: u64,
update_id: u64,
removed_entries: &[u64],
updated_entries: &[proto::Entry],
) -> tide::Result<Vec<ConnectionId>> {
@@ -548,6 +549,11 @@ impl Store {
.share
.as_mut()
.ok_or_else(|| anyhow!("worktree is not shared"))?;
if share.next_update_id != update_id {
return Err(anyhow!("received worktree updates out-of-order"))?;
}
share.next_update_id = update_id + 1;
for entry_id in removed_entries {
share.entries.remove(&entry_id);
}