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.

auto_update: Ignore dir removal errors on windows (#42435)

Lukas Wirth777b46533f63
diff --git a/crates/auto_update/src/auto_update.rs b/crates/auto_update/src/auto_update.rs
index bd44eb714c0..facb55e0df9 100644
--- a/crates/auto_update/src/auto_update.rs
+++ b/crates/auto_update/src/auto_update.rs
@@ -905,26 +905,15 @@ async fn install_release_macos(
#[cfg(target_os = "windows")]
async fn cleanup_windows() -> Result<()> {
- use util::ResultExt;
-
let parent = std::env::current_exe()?
.parent()
.context("No parent dir for Zed.exe")?
.to_owned();
// keep in sync with crates/auto_update_helper/src/updater.rs
- smol::fs::remove_dir(parent.join("updates"))
- .await
- .context("failed to remove updates dir")
- .log_err();
- smol::fs::remove_dir(parent.join("install"))
- .await
- .context("failed to remove install dir")
- .log_err();
- smol::fs::remove_dir(parent.join("old"))
- .await
- .context("failed to remove old version dir")
- .log_err();
+ _ = smol::fs::remove_dir(parent.join("updates")).await;
+ _ = smol::fs::remove_dir(parent.join("install")).await;
+ _ = smol::fs::remove_dir(parent.join("old")).await;
Ok(())
}
diff --git a/crates/auto_update_helper/src/updater.rs b/crates/auto_update_helper/src/updater.rs
index f146583d3bc..076e11fb4ee 100644
--- a/crates/auto_update_helper/src/updater.rs
+++ b/crates/auto_update_helper/src/updater.rs
@@ -1,6 +1,6 @@
use std::{
- cell::LazyCell,
path::Path,
+ sync::LazyLock,
time::{Duration, Instant},
};
@@ -13,8 +13,8 @@ use windows::Win32::{
use crate::windows_impl::WM_JOB_UPDATED;
pub(crate) struct Job {
- pub apply: Box<dyn Fn(&Path) -> Result<()>>,
- pub rollback: Box<dyn Fn(&Path) -> Result<()>>,
+ pub apply: Box<dyn Fn(&Path) -> Result<()> + Send + Sync>,
+ pub rollback: Box<dyn Fn(&Path) -> Result<()> + Send + Sync>,
}
impl Job {
@@ -154,10 +154,8 @@ impl Job {
}
}
-// app is single threaded
#[cfg(not(test))]
-#[allow(clippy::declare_interior_mutable_const)]
-pub(crate) const JOBS: LazyCell<[Job; 22]> = LazyCell::new(|| {
+pub(crate) static JOBS: LazyLock<[Job; 22]> = LazyLock::new(|| {
fn p(value: &str) -> &Path {
Path::new(value)
}
@@ -206,10 +204,8 @@ pub(crate) const JOBS: LazyCell<[Job; 22]> = LazyCell::new(|| {
]
});
-// app is single threaded
#[cfg(test)]
-#[allow(clippy::declare_interior_mutable_const)]
-pub(crate) const JOBS: LazyCell<[Job; 9]> = LazyCell::new(|| {
+pub(crate) static JOBS: LazyLock<[Job; 9]> = LazyLock::new(|| {
fn p(value: &str) -> &Path {
Path::new(value)
}