diff options
| author | David Lönnhager <david.l@mullvad.net> | 2025-02-22 15:56:56 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2025-03-05 23:32:12 +0100 |
| commit | a343c50b33f254c50fc42dd874fcbca5a84f6d3f (patch) | |
| tree | 5ce1a3d76029451cb0b44b1d9efaa4176b770a67 | |
| parent | 0fb0b75a41e30016d5bbfc9acc99ee869a880299 (diff) | |
| download | mullvadvpn-a343c50b33f254c50fc42dd874fcbca5a84f6d3f.tar.xz mullvadvpn-a343c50b33f254c50fc42dd874fcbca5a84f6d3f.zip | |
Fix launcher on macOS
| -rw-r--r-- | mullvad-update/src/app.rs | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/mullvad-update/src/app.rs b/mullvad-update/src/app.rs index f9de31c499..8987cb73bd 100644 --- a/mullvad-update/src/app.rs +++ b/mullvad-update/src/app.rs @@ -1,6 +1,6 @@ //! This module implements the flow of downloading and verifying the app. -use std::{path::PathBuf, time::Duration}; +use std::{ffi::OsString, path::PathBuf, time::Duration}; use tokio::{process::Command, time::timeout}; @@ -112,10 +112,11 @@ impl<AppProgress: ProgressUpdater> AppDownloader for HttpAppDownloader<AppProgre } async fn install(&mut self) -> Result<(), DownloadError> { - let bin_path = self.bin_path(); + let launch_path = self.launch_path(); // Launch process - let mut cmd = Command::new(bin_path); + let mut cmd = Command::new(launch_path); + cmd.args(self.launch_args()); let mut child = cmd.spawn().map_err(DownloadError::Launch)?; // Wait to see if the installer fails @@ -141,12 +142,38 @@ impl<AppProgress> HttpAppDownloader<AppProgress> { #[cfg(windows)] let bin_filename = format!("mullvad-{}.exe", self.params.app_version); - #[cfg(unix)] - let bin_filename = self.params.app_version.to_string(); + #[cfg(target_os = "macos")] + let bin_filename = format!("mullvad-{}.pkg", self.params.app_version); self.params.cache_dir.join(bin_filename) } + fn launch_path(&self) -> PathBuf { + #[cfg(target_os = "windows")] + { + self.bin_path() + } + + #[cfg(target_os = "macos")] + { + use std::path::Path; + + Path::new("/usr/bin/open").to_owned() + } + } + + fn launch_args(&self) -> Vec<OsString> { + #[cfg(target_os = "windows")] + { + vec![] + } + + #[cfg(target_os = "macos")] + { + vec![self.bin_path().into()] + } + } + fn hash_sha256(&self) -> &[u8; 32] { &self.params.app_sha256 } |
