SSH remoting: better error message for projects (#19320)
Before this, if no project paths were opened you were in a wierd UI state where most things didn't work because the project was ssh, but no files/folders were open. Release Notes: - Fixed error handling when no project paths could be opened
This commit is contained in:
parent
f6fad3b09e
commit
0c04fb9862
2 changed files with 22 additions and 13 deletions
|
@ -979,16 +979,9 @@ impl SshRemoteClient {
|
||||||
SshRemoteConnection::new(connection_options, delegate.clone(), cx).await?;
|
SshRemoteConnection::new(connection_options, delegate.clone(), cx).await?;
|
||||||
|
|
||||||
let platform = ssh_connection.query_platform().await?;
|
let platform = ssh_connection.query_platform().await?;
|
||||||
let (local_binary_path, version) = delegate.get_server_binary(platform, cx).await??;
|
|
||||||
let remote_binary_path = delegate.remote_server_binary_path(platform, cx)?;
|
let remote_binary_path = delegate.remote_server_binary_path(platform, cx)?;
|
||||||
ssh_connection
|
ssh_connection
|
||||||
.ensure_server_binary(
|
.ensure_server_binary(&delegate, &remote_binary_path, platform, cx)
|
||||||
&delegate,
|
|
||||||
&local_binary_path,
|
|
||||||
&remote_binary_path,
|
|
||||||
version,
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let socket = ssh_connection.socket.clone();
|
let socket = ssh_connection.socket.clone();
|
||||||
|
@ -1252,11 +1245,19 @@ impl SshRemoteConnection {
|
||||||
async fn ensure_server_binary(
|
async fn ensure_server_binary(
|
||||||
&self,
|
&self,
|
||||||
delegate: &Arc<dyn SshClientDelegate>,
|
delegate: &Arc<dyn SshClientDelegate>,
|
||||||
src_path: &Path,
|
|
||||||
dst_path: &Path,
|
dst_path: &Path,
|
||||||
version: SemanticVersion,
|
platform: SshPlatform,
|
||||||
cx: &mut AsyncAppContext,
|
cx: &mut AsyncAppContext,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
if std::env::var("ZED_USE_CACHED_REMOTE_SERVER").is_ok() {
|
||||||
|
if let Ok(installed_version) =
|
||||||
|
run_cmd(self.socket.ssh_command(dst_path).arg("version")).await
|
||||||
|
{
|
||||||
|
log::info!("using cached server binary version {}", installed_version);
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut dst_path_gz = dst_path.to_path_buf();
|
let mut dst_path_gz = dst_path.to_path_buf();
|
||||||
dst_path_gz.set_extension("gz");
|
dst_path_gz.set_extension("gz");
|
||||||
|
|
||||||
|
@ -1264,8 +1265,10 @@ impl SshRemoteConnection {
|
||||||
run_cmd(self.socket.ssh_command("mkdir").arg("-p").arg(parent)).await?;
|
run_cmd(self.socket.ssh_command("mkdir").arg("-p").arg(parent)).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let (src_path, version) = delegate.get_server_binary(platform, cx).await??;
|
||||||
|
|
||||||
let mut server_binary_exists = false;
|
let mut server_binary_exists = false;
|
||||||
if cfg!(not(debug_assertions)) {
|
if !server_binary_exists && cfg!(not(debug_assertions)) {
|
||||||
if let Ok(installed_version) =
|
if let Ok(installed_version) =
|
||||||
run_cmd(self.socket.ssh_command(dst_path).arg("version")).await
|
run_cmd(self.socket.ssh_command(dst_path).arg("version")).await
|
||||||
{
|
{
|
||||||
|
@ -1280,14 +1283,14 @@ impl SshRemoteConnection {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let src_stat = fs::metadata(src_path).await?;
|
let src_stat = fs::metadata(&src_path).await?;
|
||||||
let size = src_stat.len();
|
let size = src_stat.len();
|
||||||
let server_mode = 0o755;
|
let server_mode = 0o755;
|
||||||
|
|
||||||
let t0 = Instant::now();
|
let t0 = Instant::now();
|
||||||
delegate.set_status(Some("uploading remote development server"), cx);
|
delegate.set_status(Some("uploading remote development server"), cx);
|
||||||
log::info!("uploading remote development server ({}kb)", size / 1024);
|
log::info!("uploading remote development server ({}kb)", size / 1024);
|
||||||
self.upload_file(src_path, &dst_path_gz)
|
self.upload_file(&src_path, &dst_path_gz)
|
||||||
.await
|
.await
|
||||||
.context("failed to upload server binary")?;
|
.context("failed to upload server binary")?;
|
||||||
log::info!("uploaded remote development server in {:?}", t0.elapsed());
|
log::info!("uploaded remote development server in {:?}", t0.elapsed());
|
||||||
|
|
|
@ -5568,6 +5568,12 @@ pub fn open_ssh_project(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if project_paths_to_open.is_empty() {
|
||||||
|
return Err(project_path_errors
|
||||||
|
.pop()
|
||||||
|
.unwrap_or_else(|| anyhow!("no paths given")));
|
||||||
|
}
|
||||||
|
|
||||||
cx.update_window(window.into(), |_, cx| {
|
cx.update_window(window.into(), |_, cx| {
|
||||||
cx.replace_root_view(|cx| {
|
cx.replace_root_view(|cx| {
|
||||||
let mut workspace =
|
let mut workspace =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue