Keep file permissions when extracting zip archives on Unix (#31304)

Follow-up of https://github.com/zed-industries/zed/pull/31080

Stop doing

```rs
#[cfg(not(windows))]
{
    file.set_permissions(<fs::Permissions as fs::unix::PermissionsExt>::from_mode(
        0o755,
    ))
    .await?;
}
```

after extracting zip archives on Unix, and use an API that provides the
file permissions data for each archive entry.

Release Notes:

- N/A
This commit is contained in:
Kirill Bulatov
2025-05-23 20:45:32 +00:00
committed by GitHub
parent ca72efe701
commit 7341ab3980
10 changed files with 150 additions and 91 deletions
+2 -12
View File
@@ -7,7 +7,7 @@ pub use language::*;
use lsp::{DiagnosticTag, InitializeParams, LanguageServerBinary, LanguageServerName};
use project::lsp_store::clangd_ext;
use serde_json::json;
use smol::{fs, io::BufReader};
use smol::fs;
use std::{any::Any, env::consts, path::PathBuf, sync::Arc};
use util::{ResultExt, archive::extract_zip, fs::remove_matching, maybe, merge_json_value_into};
@@ -83,20 +83,10 @@ impl super::LspAdapter for CLspAdapter {
"download failed with status {}",
response.status().to_string()
);
extract_zip(&container_dir, BufReader::new(response.body_mut()))
extract_zip(&container_dir, response.body_mut())
.await
.with_context(|| format!("unzipping clangd archive to {container_dir:?}"))?;
remove_matching(&container_dir, |entry| entry != version_dir).await;
// todo("windows")
#[cfg(not(windows))]
{
fs::set_permissions(
&binary_path,
<fs::Permissions as fs::unix::PermissionsExt>::from_mode(0o755),
)
.await?;
}
}
Ok(LanguageServerBinary {