Wait for remote worktree to catch up with host before mutating entries
This ensures that entries don't randomly re-appear on remote worktrees due to observing an update too late. In fact, it ensures that the remote worktree has the same starting state of the host before preemptively applying the fs operation locally.
This commit is contained in:
@@ -448,6 +448,7 @@ impl Server {
|
||||
.cloned()
|
||||
.collect(),
|
||||
visible: worktree.visible,
|
||||
scan_id: shared_worktree.scan_id,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
@@ -578,6 +579,7 @@ impl Server {
|
||||
request.payload.worktree_id,
|
||||
&request.payload.removed_entries,
|
||||
&request.payload.updated_entries,
|
||||
request.payload.scan_id,
|
||||
)?;
|
||||
|
||||
broadcast(request.sender_id, connection_ids, |connection_id| {
|
||||
@@ -5804,6 +5806,7 @@ mod tests {
|
||||
guest_client.username,
|
||||
id
|
||||
);
|
||||
assert_eq!(guest_snapshot.scan_id(), host_snapshot.scan_id());
|
||||
}
|
||||
|
||||
guest_client
|
||||
|
||||
@@ -46,6 +46,7 @@ pub struct ProjectShare {
|
||||
pub struct WorktreeShare {
|
||||
pub entries: HashMap<u64, proto::Entry>,
|
||||
pub diagnostic_summaries: BTreeMap<PathBuf, proto::DiagnosticSummary>,
|
||||
pub scan_id: u64,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
@@ -561,6 +562,7 @@ impl Store {
|
||||
worktree_id: u64,
|
||||
removed_entries: &[u64],
|
||||
updated_entries: &[proto::Entry],
|
||||
scan_id: u64,
|
||||
) -> Result<Vec<ConnectionId>> {
|
||||
let project = self.write_project(project_id, connection_id)?;
|
||||
let worktree = project
|
||||
@@ -574,6 +576,7 @@ impl Store {
|
||||
for entry in updated_entries {
|
||||
worktree.entries.insert(entry.id, entry.clone());
|
||||
}
|
||||
worktree.scan_id = scan_id;
|
||||
let connection_ids = project.connection_ids();
|
||||
Ok(connection_ids)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user