Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

remote_server: Cleanup old server binaries on wsl (#47839)

Lukas Wirth9bfb900caa60
diff --git a/crates/paths/src/paths.rs b/crates/paths/src/paths.rs
index 870e1e71c68..1fc6ce50e40 100644
--- a/crates/paths/src/paths.rs
+++ b/crates/paths/src/paths.rs
@@ -36,6 +36,7 @@ pub fn remote_server_dir_relative() -> &'static RelPath {
*CACHED
}
+// Remove this once 223 goes stable
/// Returns the relative path to the zed_wsl_server directory on the wsl host.
pub fn remote_wsl_server_dir_relative() -> &'static RelPath {
static CACHED: LazyLock<&'static RelPath> =
diff --git a/crates/remote/src/transport/wsl.rs b/crates/remote/src/transport/wsl.rs
index 9c4b5867de6..2a1b5d5ce14 100644
--- a/crates/remote/src/transport/wsl.rs
+++ b/crates/remote/src/transport/wsl.rs
@@ -176,7 +176,7 @@ impl WslRemoteConnection {
);
let dst_path =
- paths::remote_wsl_server_dir_relative().join(RelPath::unix(&binary_name).unwrap());
+ paths::remote_server_dir_relative().join(RelPath::unix(&binary_name).unwrap());
if let Some(parent) = dst_path.parent() {
let parent = parent.display(PathStyle::Posix);
@@ -200,7 +200,7 @@ impl WslRemoteConnection {
)
.await?
{
- let tmp_path = paths::remote_wsl_server_dir_relative().join(
+ let tmp_path = paths::remote_server_dir_relative().join(
&RelPath::unix(&format!(
"download-{}-{}",
std::process::id(),
diff --git a/crates/remote_server/src/server.rs b/crates/remote_server/src/server.rs
index 53aebcf198d..f656d476a7c 100644
--- a/crates/remote_server/src/server.rs
+++ b/crates/remote_server/src/server.rs
@@ -575,8 +575,11 @@ pub fn execute_run(
handle_crash_files_requests(&project, &session);
- cx.background_spawn(async move { cleanup_old_binaries() })
- .detach();
+ cx.background_spawn(async move {
+ cleanup_old_binaries_wsl();
+ cleanup_old_binaries()
+ })
+ .detach();
mem::forget(project);
};
@@ -1174,6 +1177,15 @@ fn cleanup_old_binaries() -> Result<()> {
Ok(())
}
+// Remove this once 223 goes stable, we only have this to clean up old binaries on WSL
+// we no longer download them into this folder, we use the same folder as other remote servers
+fn cleanup_old_binaries_wsl() {
+ let server_dir = paths::remote_wsl_server_dir_relative();
+ if let Ok(()) = std::fs::remove_dir_all(server_dir.as_std_path()) {
+ log::info!("removing old wsl remote server folder: {:?}", server_dir);
+ }
+}
+
fn is_new_version(version: &str) -> bool {
semver::Version::from_str(version)
.ok()