diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2019-10-03 18:32:21 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2019-10-07 16:24:41 +0200 |
| commit | b7902119a56faf03e7a508a71e362aeaee0cd540 (patch) | |
| tree | 5120afebe06e5c4a2a27eaa5e5ee99d2c02a234a | |
| parent | 5e4c979993e9dff0200facac7cf5f4baa0b7267a (diff) | |
| download | mullvadvpn-b7902119a56faf03e7a508a71e362aeaee0cd540.tar.xz mullvadvpn-b7902119a56faf03e7a508a71e362aeaee0cd540.zip | |
Use PRODUCT_VERSION const instead of sending it around
| -rw-r--r-- | mullvad-daemon/src/lib.rs | 18 | ||||
| -rw-r--r-- | mullvad-daemon/src/main.rs | 9 | ||||
| -rw-r--r-- | mullvad-daemon/src/version_check.rs | 5 | ||||
| -rw-r--r-- | mullvad-jni/src/lib.rs | 1 |
4 files changed, 10 insertions, 23 deletions
diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index 28194733a3..b4ca11d32e 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -265,7 +265,6 @@ pub struct Daemon<L: EventListener = ManagementInterfaceEventBroadcaster> { relay_selector: relays::RelaySelector, last_generated_relay: Option<Relay>, last_generated_bridge_relay: Option<Relay>, - version: String, app_version_info: AppVersionInfo, shutdown_callbacks: Vec<Box<dyn FnOnce()>>, } @@ -275,7 +274,6 @@ impl Daemon<ManagementInterfaceEventBroadcaster> { log_dir: Option<PathBuf>, resource_dir: PathBuf, cache_dir: PathBuf, - version: String, ) -> Result<Self> { if rpc_uniqueness_check::is_another_instance_running() { return Err(Error::DaemonIsAlreadyRunning); @@ -291,7 +289,6 @@ impl Daemon<ManagementInterfaceEventBroadcaster> { log_dir, resource_dir, cache_dir, - version, ) } @@ -339,7 +336,6 @@ where log_dir: Option<PathBuf>, resource_dir: PathBuf, cache_dir: PathBuf, - version: String, ) -> Result<Self> { let (tx, rx) = mpsc::channel(); @@ -351,7 +347,6 @@ where log_dir, resource_dir, cache_dir, - version, ) } @@ -363,7 +358,6 @@ where log_dir: Option<PathBuf>, resource_dir: PathBuf, cache_dir: PathBuf, - version: String, ) -> Result<Self> { let ca_path = resource_dir.join(mullvad_paths::resources::API_CA_FILENAME); @@ -410,13 +404,12 @@ where AppVersionInfo { current_is_supported: true, current_is_outdated: false, - latest_stable: version.clone(), - latest: version.clone(), + latest_stable: version::PRODUCT_VERSION.to_owned(), + latest: version::PRODUCT_VERSION.to_owned(), } } }; let version_check_future = version_check::VersionUpdater::new( - version.clone(), rpc_handle.clone(), cache_dir.clone(), on_version_check_update, @@ -473,7 +466,6 @@ where relay_selector, last_generated_relay: None, last_generated_bridge_relay: None, - version, app_version_info, shutdown_callbacks: vec![], }; @@ -1109,7 +1101,11 @@ where } fn on_get_current_version(&mut self, tx: oneshot::Sender<AppVersion>) { - Self::oneshot_send(tx, self.version.clone(), "get_current_version response"); + Self::oneshot_send( + tx, + version::PRODUCT_VERSION.to_owned(), + "get_current_version response", + ); } #[cfg(not(target_os = "android"))] diff --git a/mullvad-daemon/src/main.rs b/mullvad-daemon/src/main.rs index 9d4ca0fb56..26e463ef70 100644 --- a/mullvad-daemon/src/main.rs +++ b/mullvad-daemon/src/main.rs @@ -110,13 +110,8 @@ fn create_daemon(log_dir: Option<PathBuf>) -> Result<Daemon, String> { let cache_dir = mullvad_paths::cache_dir() .map_err(|e| e.display_chain_with_msg("Unable to get cache dir"))?; - Daemon::start( - log_dir, - resource_dir, - cache_dir, - version::PRODUCT_VERSION.to_owned(), - ) - .map_err(|e| e.display_chain_with_msg("Unable to initialize daemon")) + Daemon::start(log_dir, resource_dir, cache_dir) + .map_err(|e| e.display_chain_with_msg("Unable to initialize daemon")) } #[cfg(unix)] diff --git a/mullvad-daemon/src/version_check.rs b/mullvad-daemon/src/version_check.rs index 604bc3c672..8ba637c930 100644 --- a/mullvad-daemon/src/version_check.rs +++ b/mullvad-daemon/src/version_check.rs @@ -30,7 +30,6 @@ const PLATFORM: &str = "windows"; const PLATFORM: &str = "android"; pub struct VersionUpdater<F: Fn(&AppVersionInfo) + Send + 'static> { - version: String, version_proxy: AppVersionProxy<HttpHandle>, cache_dir: PathBuf, on_version_update: F, @@ -46,7 +45,6 @@ enum VersionUpdaterState { impl<F: Fn(&AppVersionInfo) + Send + 'static> VersionUpdater<F> { pub fn new( - version: String, rpc_handle: HttpHandle, cache_dir: PathBuf, on_version_update: F, @@ -54,7 +52,6 @@ impl<F: Fn(&AppVersionInfo) + Send + 'static> VersionUpdater<F> { ) -> Self { let version_proxy = AppVersionProxy::new(rpc_handle); Self { - version, version_proxy, cache_dir, on_version_update, @@ -122,7 +119,7 @@ impl<F: Fn(&AppVersionInfo) + Send + 'static> VersionUpdater<F> { ) -> Box<dyn Future<Item = AppVersionInfo, Error = Error> + Send + 'static> { let download_future = self .version_proxy - .app_version_check(&self.version, PLATFORM) + .app_version_check(&crate::version::PRODUCT_VERSION.to_owned(), PLATFORM) .map_err(Error::Download); let future = Timer::default().timeout(download_future, DOWNLOAD_TIMEOUT); Box::new(future) diff --git a/mullvad-jni/src/lib.rs b/mullvad-jni/src/lib.rs index c1d85a5a6c..e4ed6c83a5 100644 --- a/mullvad-jni/src/lib.rs +++ b/mullvad-jni/src/lib.rs @@ -228,7 +228,6 @@ fn create_daemon( Some(log_dir), resource_dir, cache_dir, - version::PRODUCT_VERSION.to_owned(), ) .map_err(Error::InitializeDaemon)?; |
