diff options
| author | Sebastian Holmin <sebastian.holmin@mullvad.net> | 2025-05-06 11:41:10 +0200 |
|---|---|---|
| committer | Sebastian Holmin <sebastian.holmin@mullvad.net> | 2025-05-28 13:25:32 +0200 |
| commit | 51a9c434a689846bfa1e59381cc50bc46ce491ae (patch) | |
| tree | ae4b66dea6f5102c3022ec0f7001f79c7982062b | |
| parent | 9abf74046303b55bca81051c05130b2ee77ffa89 (diff) | |
| download | mullvadvpn-51a9c434a689846bfa1e59381cc50bc46ce491ae.tar.xz mullvadvpn-51a9c434a689846bfa1e59381cc50bc46ce491ae.zip | |
Always reset to `HasVersion` on new version
| -rw-r--r-- | mullvad-daemon/src/version/router.rs | 58 | ||||
| -rw-r--r-- | mullvad-management-interface/proto/management_interface.proto | 2 |
2 files changed, 14 insertions, 46 deletions
diff --git a/mullvad-daemon/src/version/router.rs b/mullvad-daemon/src/version/router.rs index c7bbc311e6..02041a493b 100644 --- a/mullvad-daemon/src/version/router.rs +++ b/mullvad-daemon/src/version/router.rs @@ -306,13 +306,11 @@ where /// If the router is in the process of upgrading, it will not propagate versions, but only /// remember it for when it transitions back into the "idle" (version check) state. fn on_new_version(&mut self, version_cache: VersionCache) -> AppVersionInfoEvent { - #[cfg(update)] - let verified_installer_path = self.get_verified_installer_path(); - match &mut self.state { + let new_app_version_info = match &mut self.state { State::NoVersion => { // Receive first version let app_version_info = to_app_version_info(&version_cache, self.beta_program, None); - self.state = State::HasVersion { version_cache }; + AppVersionInfoEvent { app_version_info, is_new: true, @@ -325,44 +323,24 @@ where let prev_app_version = to_app_version_info(prev_cache, self.beta_program, None); let new_app_version = to_app_version_info(&version_cache, self.beta_program, None); - self.state = State::HasVersion { version_cache }; - AppVersionInfoEvent { is_new: new_app_version != prev_app_version, app_version_info: new_app_version, } } #[cfg(update)] - State::Downloaded { - version_cache: ref mut prev_cache, - .. - } - | State::Downloading { - version_cache: ref mut prev_cache, - .. - } => { - let prev_app_version = to_app_version_info( - prev_cache, - self.beta_program, - verified_installer_path.clone(), - ); - let new_app_version = - to_app_version_info(&version_cache, self.beta_program, verified_installer_path); + State::Downloaded { .. } | State::Downloading { .. } => { + let app_version_info = to_app_version_info(&version_cache, self.beta_program, None); - let is_new = new_app_version != prev_app_version; - // If version changed, cancel download by switching state - if is_new { - log::warn!("Received new version while upgrading: {new_app_version:?}"); - self.state = State::HasVersion { version_cache }; - } else { - *prev_cache = version_cache; - }; + log::warn!("Received new version while upgrading: {app_version_info:?}"); AppVersionInfoEvent { - app_version_info: new_app_version, - is_new, + app_version_info, + is_new: true, } } - } + }; + self.state = State::HasVersion { version_cache }; + new_app_version_info } fn notify_version_requesters(&mut self, new_app_version_info: AppVersionInfo) { @@ -372,17 +350,6 @@ where } } - #[cfg(update)] - fn get_verified_installer_path(&self) -> Option<PathBuf> { - match &self.state { - State::Downloaded { - verified_installer_path, - .. - } => Some(verified_installer_path.clone()), - _ => None, - } - } - fn set_beta_program(&mut self, new_state: bool) { if new_state == self.beta_program { return; @@ -985,17 +952,16 @@ mod test { // Check that the state is now downloading assert!(matches!(version_router.state, State::Downloading { .. }),); + // Advance the download to the point where we have started downloading tokio::time::sleep(DOWNLOAD_DURATION / 2).await; - version_router.on_new_version(upgrade_version); - assert_eq!( app_upgrade_listener.try_recv().unwrap(), AppUpgradeEvent::DownloadStarting ); assert_eq!(app_upgrade_listener.try_recv(), Err(TryRecvError::Empty)); + // Now, send a new version while the download is in progress version_router.on_new_version(upgrade_version_newer); - assert_eq!( app_upgrade_listener.try_recv().unwrap(), AppUpgradeEvent::Aborted diff --git a/mullvad-management-interface/proto/management_interface.proto b/mullvad-management-interface/proto/management_interface.proto index a7e5e7a18c..4accf8f5bc 100644 --- a/mullvad-management-interface/proto/management_interface.proto +++ b/mullvad-management-interface/proto/management_interface.proto @@ -25,6 +25,8 @@ service ManagementService { rpc FactoryReset(google.protobuf.Empty) returns (google.protobuf.Empty) {} rpc GetCurrentVersion(google.protobuf.Empty) returns (google.protobuf.StringValue) {} + // Get information about the latest available version of the app. + // Note that calling this during an in-app upgrade will cancel the upgrade. rpc GetVersionInfo(google.protobuf.Empty) returns (AppVersionInfo) {} rpc IsPerformingPostUpgrade(google.protobuf.Empty) returns (google.protobuf.BoolValue) {} |
