ssh project: Handle multiple paths and worktrees correctly (#18277)

This makes SSH projects work with `ssh_connections` that have multiple
paths:

```json
{
  "ssh_connections": [
    {
      "host": "127.0.0.1",
      "projects": [
        {
          "paths": [
            "/Users/thorstenball/work/projs/go-proj",
            "/Users/thorstenball/work/projs/rust-proj"
          ]
        }
      ]
    }
  ]
}
```

@ConradIrwin @mikayla-maki since this wasn't really released yet, we
didn't create a full-on migration, so old ssh projects that were already
serialized need to either be manually deleted from the database, or the
whole local DB wiped.

Release Notes:

- N/A

---------

Co-authored-by: Bennet <bennet@zed.dev>
This commit is contained in:
Thorsten Ball 2024-09-24 16:46:11 +02:00 committed by GitHub
parent 3a2f0653d1
commit 437bcc0ce6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 66 additions and 56 deletions

View file

@ -5516,14 +5516,14 @@ pub fn open_ssh_project(
cx: &mut AppContext,
) -> Task<Result<()>> {
cx.spawn(|mut cx| async move {
// TODO: Handle multiple paths
let path = paths.iter().next().cloned().unwrap_or_default();
let serialized_ssh_project = persistence::DB
.get_or_create_ssh_project(
connection_options.host.clone(),
connection_options.port,
path.to_string_lossy().to_string(),
paths
.iter()
.map(|path| path.to_string_lossy().to_string())
.collect::<Vec<_>>(),
connection_options.username.clone(),
)
.await?;