From 3e7a2e5c3067c53bb12cd0c76c6e7b09af7c8fcf Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 24 Oct 2024 15:10:54 +0200 Subject: [PATCH] Split worktree updates coming from an SSH server Previously, we would send the initial set of paths / changeset for a worktree in its entirety and we think this was causing the server to panic. Co-Authored-By: Thorsten Co-Authored-By: Bennet Co-Authored-By: Kirill --- crates/worktree/src/worktree.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index 2354358553f..722a7b3f0ab 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -36,7 +36,10 @@ use postage::{ prelude::{Sink as _, Stream as _}, watch, }; -use rpc::{proto, AnyProtoClient}; +use rpc::{ + proto::{self, split_worktree_update}, + AnyProtoClient, +}; pub use settings::WorktreeId; use settings::{Settings, SettingsLocation, SettingsStore}; use smallvec::{smallvec, SmallVec}; @@ -1812,13 +1815,17 @@ impl RemoteWorktree { self.update_observer = Some(tx); cx.spawn(|this, mut cx| async move { let mut update = initial_update; - loop { + 'outer: loop { // SSH projects use a special project ID of 0, and we need to // remap it to the correct one here. update.project_id = project_id; - if !callback(update).await { - break; + + for chunk in split_worktree_update(update) { + if !callback(chunk).await { + break 'outer; + } } + if let Some(next_update) = rx.next().await { update = next_update; } else {