Extension refactor (#20305)
This contains the main changes to the extensions crate from #20049. The primary goal here is removing dependencies that we can't include on the remote. Release Notes: - N/A --------- Co-authored-by: Mikayla <mikayla@zed.dev> Co-authored-by: Marshall Bowers <elliott.codes@gmail.com> Co-authored-by: Marshall <marshall@zed.dev>
This commit is contained in:
parent
f22e56ff42
commit
608addf641
30 changed files with 675 additions and 236 deletions
|
@ -990,6 +990,19 @@ impl SshRemoteClient {
|
|||
.map(|ssh_connection| ssh_connection.ssh_args())
|
||||
}
|
||||
|
||||
pub fn upload_directory(
|
||||
&self,
|
||||
src_path: PathBuf,
|
||||
dest_path: PathBuf,
|
||||
cx: &AppContext,
|
||||
) -> Task<Result<()>> {
|
||||
let state = self.state.lock();
|
||||
let Some(connection) = state.as_ref().and_then(|state| state.ssh_connection()) else {
|
||||
return Task::ready(Err(anyhow!("no ssh connection")));
|
||||
};
|
||||
connection.upload_directory(src_path, dest_path, cx)
|
||||
}
|
||||
|
||||
pub fn proto_client(&self) -> AnyProtoClient {
|
||||
self.client.clone().into()
|
||||
}
|
||||
|
@ -1194,6 +1207,12 @@ trait RemoteConnection: Send + Sync {
|
|||
delegate: Arc<dyn SshClientDelegate>,
|
||||
cx: &mut AsyncAppContext,
|
||||
) -> Task<Result<i32>>;
|
||||
fn upload_directory(
|
||||
&self,
|
||||
src_path: PathBuf,
|
||||
dest_path: PathBuf,
|
||||
cx: &AppContext,
|
||||
) -> Task<Result<()>>;
|
||||
async fn kill(&self) -> Result<()>;
|
||||
fn has_been_killed(&self) -> bool;
|
||||
fn ssh_args(&self) -> Vec<String>;
|
||||
|
@ -1232,6 +1251,49 @@ impl RemoteConnection for SshRemoteConnection {
|
|||
fn connection_options(&self) -> SshConnectionOptions {
|
||||
self.socket.connection_options.clone()
|
||||
}
|
||||
|
||||
fn upload_directory(
|
||||
&self,
|
||||
src_path: PathBuf,
|
||||
dest_path: PathBuf,
|
||||
cx: &AppContext,
|
||||
) -> Task<Result<()>> {
|
||||
let mut command = process::Command::new("scp");
|
||||
let output = self
|
||||
.socket
|
||||
.ssh_options(&mut command)
|
||||
.args(
|
||||
self.socket
|
||||
.connection_options
|
||||
.port
|
||||
.map(|port| vec!["-P".to_string(), port.to_string()])
|
||||
.unwrap_or_default(),
|
||||
)
|
||||
.arg("-r")
|
||||
.arg(&src_path)
|
||||
.arg(format!(
|
||||
"{}:{}",
|
||||
self.socket.connection_options.scp_url(),
|
||||
dest_path.display()
|
||||
))
|
||||
.output();
|
||||
|
||||
cx.background_executor().spawn(async move {
|
||||
let output = output.await?;
|
||||
|
||||
if !output.status.success() {
|
||||
return Err(anyhow!(
|
||||
"failed to upload directory {} -> {}: {}",
|
||||
src_path.display(),
|
||||
dest_path.display(),
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
fn start_proxy(
|
||||
&self,
|
||||
unique_identifier: String,
|
||||
|
@ -2286,7 +2348,7 @@ mod fake {
|
|||
},
|
||||
select_biased, FutureExt, SinkExt, StreamExt,
|
||||
};
|
||||
use gpui::{AsyncAppContext, SemanticVersion, Task, TestAppContext};
|
||||
use gpui::{AppContext, AsyncAppContext, SemanticVersion, Task, TestAppContext};
|
||||
use release_channel::ReleaseChannel;
|
||||
use rpc::proto::Envelope;
|
||||
|
||||
|
@ -2330,6 +2392,14 @@ mod fake {
|
|||
fn ssh_args(&self) -> Vec<String> {
|
||||
Vec::new()
|
||||
}
|
||||
fn upload_directory(
|
||||
&self,
|
||||
_src_path: PathBuf,
|
||||
_dest_path: PathBuf,
|
||||
_cx: &AppContext,
|
||||
) -> Task<Result<()>> {
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
fn connection_options(&self) -> SshConnectionOptions {
|
||||
self.connection_options.clone()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue