Ensure worktree updates are observed in order on the server
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user