diff --git a/crates/collab/src/rpc/store.rs b/crates/collab/src/rpc/store.rs index 2e69a97b27..7a327e4d35 100644 --- a/crates/collab/src/rpc/store.rs +++ b/crates/collab/src/rpc/store.rs @@ -657,6 +657,10 @@ impl Store { scan_id: u64, ) -> Result<(Vec, bool, HashMap)> { let project = self.write_project(project_id, connection_id)?; + if !project.online { + return Err(anyhow!("project is not online")); + } + let connection_ids = project.connection_ids(); let mut worktree = project.worktrees.entry(worktree_id).or_default(); let metadata_changed = worktree_root_name != worktree.root_name; diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 4e3f783330..2658adaa6d 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -1243,6 +1243,10 @@ impl Project { } fn share(&mut self, cx: &mut ModelContext) -> Task> { + if !self.is_online() { + return Task::ready(Err(anyhow!("can't share an offline project"))); + } + let project_id; if let ProjectClientState::Local { remote_id_rx, @@ -1358,11 +1362,17 @@ impl Project { cx: &mut ModelContext, ) { if let Some(project_id) = self.remote_id() { - let share = self.share(cx); + let share = if self.is_online() && allow { + Some(self.share(cx)) + } else { + None + }; let client = self.client.clone(); cx.foreground() .spawn(async move { - share.await?; + if let Some(share) = share { + share.await?; + } client.send(proto::RespondToJoinProjectRequest { requester_id, project_id,