WIP: ssh remoting: Add upload_binary field to SshConnections (#19748)

This removes the old `remote_server { "download_binary_on_host": bool }`
field and replaces it with a `upload_binary: bool` on every
`ssh_connection`.


@ConradIrwin it compiles, it connects, but I haven't tested it really
yet

Release Notes:

- N/A

---------

Co-authored-by: Conrad <conrad@zed.dev>
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Thorsten Ball
2024-10-25 17:32:54 -06:00
committed by GitHub
co-authored by Conrad Conrad Irwin
parent 1acebb3c47
commit fc8a72cdd8
11 changed files with 204 additions and 235 deletions
+6 -34
View File
@@ -25,7 +25,6 @@ use gpui::{
use http_client::{read_proxy_from_env, Uri};
use language::LanguageRegistry;
use log::LevelFilter;
use remote::SshConnectionOptions;
use reqwest_client::ReqwestClient;
use assets::Assets;
@@ -616,26 +615,15 @@ fn handle_open_request(request: OpenRequest, app_state: Arc<AppState>, cx: &mut
return;
}
if let Some(connection_info) = request.ssh_connection {
if let Some(connection_options) = request.ssh_connection {
cx.spawn(|mut cx| async move {
let nickname = cx
.update(|cx| {
SshSettings::get_global(cx).nickname_for(
&connection_info.host,
connection_info.port,
&connection_info.username,
)
})
.ok()
.flatten();
let paths_with_position =
derive_paths_with_position(app_state.fs.as_ref(), request.open_paths).await;
open_ssh_project(
connection_info,
connection_options,
paths_with_position.into_iter().map(|p| p.path).collect(),
app_state,
workspace::OpenOptions::default(),
nickname,
&mut cx,
)
.await
@@ -798,25 +786,10 @@ async fn restore_or_create_workspace(
task.await?;
}
SerializedWorkspaceLocation::Ssh(ssh) => {
let args = cx
.update(|cx| {
SshSettings::get_global(cx).args_for(&ssh.host, ssh.port, &ssh.user)
})
.ok()
.flatten();
let nickname = cx
.update(|cx| {
SshSettings::get_global(cx).nickname_for(&ssh.host, ssh.port, &ssh.user)
})
.ok()
.flatten();
let connection_options = SshConnectionOptions {
args,
host: ssh.host.clone(),
username: ssh.user.clone(),
port: ssh.port,
password: None,
};
let connection_options = cx.update(|cx| {
SshSettings::get_global(cx)
.connection_options_for(ssh.host, ssh.port, ssh.user)
})?;
let app_state = app_state.clone();
cx.spawn(move |mut cx| async move {
recent_projects::open_ssh_project(
@@ -824,7 +797,6 @@ async fn restore_or_create_workspace(
ssh.paths.into_iter().map(PathBuf::from).collect(),
app_state,
workspace::OpenOptions::default(),
nickname,
&mut cx,
)
.await
-7
View File
@@ -881,12 +881,6 @@ pub fn open_new_ssh_project_from_project(
return Task::ready(Err(anyhow::anyhow!("Not an ssh project")));
};
let connection_options = ssh_client.read(cx).connection_options();
let nickname = recent_projects::SshSettings::get_global(cx).nickname_for(
&connection_options.host,
connection_options.port,
&connection_options.username,
);
cx.spawn(|_, mut cx| async move {
open_ssh_project(
connection_options,
@@ -897,7 +891,6 @@ pub fn open_new_ssh_project_from_project(
replace_window: None,
env: None,
},
nickname,
&mut cx,
)
.await
+30 -43
View File
@@ -72,25 +72,24 @@ impl OpenRequest {
.ok_or_else(|| anyhow!("missing host in ssh url: {}", file))?
.to_string();
let username = Some(url.username().to_string()).filter(|s| !s.is_empty());
let password = url.password().map(|s| s.to_string());
let port = url.port();
if !self.open_paths.is_empty() {
return Err(anyhow!("cannot open both local and ssh paths"));
}
let args = SshSettings::get_global(cx).args_for(&host, port, &username);
let connection = SshConnectionOptions {
username,
password,
host,
let mut connection_options = SshSettings::get_global(cx).connection_options_for(
host.clone(),
port,
args,
};
username.clone(),
);
if let Some(password) = url.password() {
connection_options.password = Some(password.to_string());
}
if let Some(ssh_connection) = &self.ssh_connection {
if *ssh_connection != connection {
if *ssh_connection != connection_options {
return Err(anyhow!("cannot open multiple ssh connections"));
}
}
self.ssh_connection = Some(connection);
self.ssh_connection = Some(connection_options);
self.parse_file_path(url.path());
Ok(())
}
@@ -374,40 +373,28 @@ async fn open_workspaces(
}
SerializedWorkspaceLocation::Ssh(ssh) => {
let app_state = app_state.clone();
let args = cx
.update(|cx| {
SshSettings::get_global(cx).args_for(&ssh.host, ssh.port, &ssh.user)
let connection_options = cx.update(|cx| {
SshSettings::get_global(cx)
.connection_options_for(ssh.host, ssh.port, ssh.user)
});
if let Ok(connection_options) = connection_options {
cx.spawn(|mut cx| async move {
open_ssh_project(
connection_options,
ssh.paths.into_iter().map(PathBuf::from).collect(),
app_state,
OpenOptions::default(),
&mut cx,
)
.await
.log_err();
})
.ok()
.flatten();
let connection_options = SshConnectionOptions {
args,
host: ssh.host.clone(),
username: ssh.user.clone(),
port: ssh.port,
password: None,
};
let nickname = cx
.update(|cx| {
SshSettings::get_global(cx).nickname_for(&ssh.host, ssh.port, &ssh.user)
})
.ok()
.flatten();
cx.spawn(|mut cx| async move {
open_ssh_project(
connection_options,
ssh.paths.into_iter().map(PathBuf::from).collect(),
app_state,
OpenOptions::default(),
nickname,
&mut cx,
)
.await
.log_err();
})
.detach();
// We don't set `errored` here, because for ssh projects, the
// error is displayed in the window.
.detach();
// We don't set `errored` here if `open_ssh_project` fails, because for ssh projects, the
// error is displayed in the window.
} else {
errored = false;
}
}
}
}