Respond to join project request before sharing project completes

This ensures the guest doesn't observe a huge delay when joining.
This commit is contained in:
Antonio Scandurra 2022-06-30 14:29:06 +02:00
parent 09bb3ddeb8
commit 845c79ee05
2 changed files with 6 additions and 7 deletions

View file

@ -1332,12 +1332,13 @@ impl Project {
let client = self.client.clone();
cx.foreground()
.spawn(async move {
share.await?;
client.send(proto::RespondToJoinProjectRequest {
requester_id,
project_id,
allow,
})
})?;
share.await?;
anyhow::Ok(())
})
.detach_and_log_err(cx);
}

View file

@ -2718,10 +2718,11 @@ async fn send_worktree_update(
#[cfg(not(any(test, feature = "test-support")))]
const MAX_CHUNK_SIZE: usize = 256;
loop {
let mut is_last_update = false;
while !is_last_update {
let chunk_size = cmp::min(update.updated_entries.len(), MAX_CHUNK_SIZE);
let updated_entries = update.updated_entries.drain(..chunk_size).collect();
let is_last_update = update.updated_entries.is_empty();
is_last_update = update.updated_entries.is_empty();
client
.request(proto::UpdateWorktree {
project_id: update.project_id,
@ -2733,9 +2734,6 @@ async fn send_worktree_update(
is_last_update,
})
.await?;
if is_last_update {
break;
}
}
Ok(())