remote server: Fix error log about inability to open buffer (#19824)
Turns out that we used client-side `fs` to check whether something is a directory or not, which obviously doesn't work with SSH projects. Release Notes: - N/A --------- Co-authored-by: Bennet <bennet@zed.dev>
This commit is contained in:
parent
5e89fba681
commit
cc81f19c68
8 changed files with 213 additions and 59 deletions
|
@ -1218,7 +1218,7 @@ impl Workspace {
|
|||
notify_if_database_failed(window, &mut cx);
|
||||
let opened_items = window
|
||||
.update(&mut cx, |_workspace, cx| {
|
||||
open_items(serialized_workspace, project_paths, app_state, cx)
|
||||
open_items(serialized_workspace, project_paths, cx)
|
||||
})?
|
||||
.await
|
||||
.unwrap_or_default();
|
||||
|
@ -2058,8 +2058,10 @@ impl Workspace {
|
|||
cx: &mut ViewContext<Self>,
|
||||
) -> Task<anyhow::Result<Box<dyn ItemHandle>>> {
|
||||
match path {
|
||||
ResolvedPath::ProjectPath(project_path) => self.open_path(project_path, None, true, cx),
|
||||
ResolvedPath::AbsPath(path) => self.open_abs_path(path, false, cx),
|
||||
ResolvedPath::ProjectPath { project_path, .. } => {
|
||||
self.open_path(project_path, None, true, cx)
|
||||
}
|
||||
ResolvedPath::AbsPath { path, .. } => self.open_abs_path(path, false, cx),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4563,7 +4565,6 @@ fn window_bounds_env_override() -> Option<Bounds<Pixels>> {
|
|||
fn open_items(
|
||||
serialized_workspace: Option<SerializedWorkspace>,
|
||||
mut project_paths_to_open: Vec<(PathBuf, Option<ProjectPath>)>,
|
||||
app_state: Arc<AppState>,
|
||||
cx: &mut ViewContext<Workspace>,
|
||||
) -> impl 'static + Future<Output = Result<Vec<Option<Result<Box<dyn ItemHandle>>>>>> {
|
||||
let restored_items = serialized_workspace.map(|serialized_workspace| {
|
||||
|
@ -4619,14 +4620,20 @@ fn open_items(
|
|||
.enumerate()
|
||||
.map(|(ix, (abs_path, project_path))| {
|
||||
let workspace = workspace.clone();
|
||||
cx.spawn(|mut cx| {
|
||||
let fs = app_state.fs.clone();
|
||||
async move {
|
||||
let file_project_path = project_path?;
|
||||
if fs.is_dir(&abs_path).await {
|
||||
None
|
||||
} else {
|
||||
Some((
|
||||
cx.spawn(|mut cx| async move {
|
||||
let file_project_path = project_path?;
|
||||
let abs_path_task = workspace.update(&mut cx, |workspace, cx| {
|
||||
workspace.project().update(cx, |project, cx| {
|
||||
project.resolve_abs_path(abs_path.to_string_lossy().as_ref(), cx)
|
||||
})
|
||||
});
|
||||
|
||||
// We only want to open file paths here. If one of the items
|
||||
// here is a directory, it was already opened further above
|
||||
// with a `find_or_create_worktree`.
|
||||
if let Ok(task) = abs_path_task {
|
||||
if task.await.map_or(true, |p| p.is_file()) {
|
||||
return Some((
|
||||
ix,
|
||||
workspace
|
||||
.update(&mut cx, |workspace, cx| {
|
||||
|
@ -4634,9 +4641,10 @@ fn open_items(
|
|||
})
|
||||
.log_err()?
|
||||
.await,
|
||||
))
|
||||
));
|
||||
}
|
||||
}
|
||||
None
|
||||
})
|
||||
});
|
||||
|
||||
|
@ -5580,7 +5588,7 @@ pub fn open_ssh_project(
|
|||
.update(&mut cx, |_, cx| {
|
||||
cx.activate_window();
|
||||
|
||||
open_items(serialized_workspace, project_paths_to_open, app_state, cx)
|
||||
open_items(serialized_workspace, project_paths_to_open, cx)
|
||||
})?
|
||||
.await?;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue