Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Unmount the auto-update disk image regardless of the auto-update status (#17019)
Vitaly Slobodinca2eb275de80
diff --git a/crates/auto_update/src/auto_update.rs b/crates/auto_update/src/auto_update.rsindex 6e52154c1b2..4474357dd69 100644--- a/crates/auto_update/src/auto_update.rs+++ b/crates/auto_update/src/auto_update.rs@@ -88,6 +88,34 @@ struct JsonRelease {url: String,}+struct MacOsUnmounter {+ mount_path: PathBuf,+}++impl Drop for MacOsUnmounter {+ fn drop(&mut self) {+ let unmount_output = std::process::Command::new("hdiutil")+ .args(&["detach", "-force"])+ .arg(&self.mount_path)+ .output();++ match unmount_output {+ Ok(output) if output.status.success() => {+ log::info!("Successfully unmounted the disk image");+ }+ Ok(output) => {+ log::error!(+ "Failed to unmount disk image: {:?}",+ String::from_utf8_lossy(&output.stderr)+ );+ }+ Err(error) => {+ log::error!("Error while trying to unmount disk image: {:?}", error);+ }+ }+ }+}+struct AutoUpdateSetting(bool);/// Whether or not to automatically check for updates.@@ -739,6 +767,11 @@ async fn install_release_macos(String::from_utf8_lossy(&output.stderr));+ // Create an MacOsUnmounter that will be dropped (and thus unmount the disk) when this function exits+ let _unmounter = MacOsUnmounter {+ mount_path: mount_path.clone(),+ };+let output = Command::new("rsync").args(&["-av", "--delete"]).arg(&mounted_app_path)@@ -752,17 +785,5 @@ async fn install_release_macos(String::from_utf8_lossy(&output.stderr));- let output = Command::new("hdiutil")- .args(&["detach"])- .arg(&mount_path)- .output()- .await?;-- anyhow::ensure!(- output.status.success(),- "failed to unount: {:?}",- String::from_utf8_lossy(&output.stderr)- );-Ok(running_app_path)}