Remove ShareWorktree message

Instead, create an empty worktree on guests when a worktree is first *registered*, then update it via an initial UpdateWorktree message.

This prevents the host from referencing a worktree in definition RPC responses that hasn't yet been observed by the guest. We could have waited until the entire worktree was shared, but this could take a long time, so instead we create an empty one on guests and proceed from there.

We still have randomized test failures as of this commit:

SEED=9519 MAX_PEERS=2 ITERATIONS=10000 OPERATIONS=7 ct -p zed-server test_random_collaboration

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
Nathan Sobo 2022-02-23 11:56:09 -07:00
parent d1b4384f80
commit 17c9aa1819
5 changed files with 63 additions and 55 deletions

View file

@ -334,16 +334,16 @@ impl Server {
replica_id: 0,
user_id: joined.project.host_user_id.to_proto(),
});
let worktrees = joined
.project
let worktrees = share
.worktrees
.iter()
.filter_map(|(id, worktree)| {
worktree.share.as_ref().map(|share| proto::Worktree {
.filter_map(|(id, shared_worktree)| {
let worktree = joined.project.worktrees.get(&id)?;
Some(proto::Worktree {
id: *id,
root_name: worktree.root_name.clone(),
entries: share.entries.values().cloned().collect(),
diagnostic_summaries: share
entries: shared_worktree.entries.values().cloned().collect(),
diagnostic_summaries: shared_worktree
.diagnostic_summaries
.values()
.cloned()
@ -437,7 +437,6 @@ impl Server {
Worktree {
authorized_user_ids: contact_user_ids.clone(),
root_name: request.payload.root_name.clone(),
share: None,
weak: request.payload.weak,
},
)?;
@ -1164,7 +1163,7 @@ mod tests {
cell::Cell,
env,
ops::Deref,
path::Path,
path::{Path, PathBuf},
rc::Rc,
sync::{
atomic::{AtomicBool, Ordering::SeqCst},
@ -2115,16 +2114,14 @@ mod tests {
let worktree = store
.project(project_id)
.unwrap()
.share
.as_ref()
.unwrap()
.worktrees
.get(&worktree_id.to_proto())
.unwrap();
!worktree
.share
.as_ref()
.unwrap()
.diagnostic_summaries
.is_empty()
!worktree.diagnostic_summaries.is_empty()
})
.await;