diff options
| author | David Lönnhager <david.l@mullvad.net> | 2025-10-17 17:22:42 +0200 |
|---|---|---|
| committer | Joakim Hulthe <joakim.hulthe@mullvad.net> | 2025-10-23 10:22:46 +0200 |
| commit | 541b99f0997beca34e612c87d598093ed7c1d9d6 (patch) | |
| tree | b967be664f6a60ac5146a160a6841b69f8d2de2e | |
| parent | 82920c6f3702bc41028519dba318e39bd44cc52a (diff) | |
| download | mullvadvpn-541b99f0997beca34e612c87d598093ed7c1d9d6.tar.xz mullvadvpn-541b99f0997beca34e612c87d598093ed7c1d9d6.zip | |
Do not cancel download when version check is invoked
| -rw-r--r-- | mullvad-daemon/src/version/router.rs | 60 |
1 files changed, 56 insertions, 4 deletions
diff --git a/mullvad-daemon/src/version/router.rs b/mullvad-daemon/src/version/router.rs index 7f878a94bc..cd7e63de03 100644 --- a/mullvad-daemon/src/version/router.rs +++ b/mullvad-daemon/src/version/router.rs @@ -351,14 +351,66 @@ where } } #[cfg(in_app_upgrade)] - State::Downloaded { .. } | State::Downloading { .. } => { + State::Downloading { + version_cache: prev_cache, + .. + } => { + let prev_app_version_info = + to_app_version_info(prev_cache, self.beta_program, None); let app_version_info = to_app_version_info(&version_cache, self.beta_program, None); - log::warn!("Received new version while upgrading: {app_version_info:?}"); - AppVersionInfoEvent { + let event = AppVersionInfoEvent { + is_new: prev_app_version_info != app_version_info, app_version_info, - is_new: true, + }; + + if !event.is_new { + log::trace!("Ignoring same version in downloading state"); + // Return here to avoid resetting the state to `HasVersion` + // We update the cache because ignored information (eg available beta if beta + // program is off) may have changed + *prev_cache = version_cache.clone(); + return event; + } + + log::warn!("Received new version while downloading. Aborting download"); + + event + } + #[cfg(in_app_upgrade)] + State::Downloaded { + version_cache: prev_cache, + verified_installer_path, + .. + } => { + let prev_app_version_info = to_app_version_info( + prev_cache, + self.beta_program, + Some(verified_installer_path.clone()), + ); + let app_version_info = to_app_version_info( + &version_cache, + self.beta_program, + Some(verified_installer_path.clone()), + ); + + let event = AppVersionInfoEvent { + is_new: prev_app_version_info != app_version_info, + app_version_info, + }; + + if !event.is_new { + log::trace!("Ignoring same version in downloaded state"); + // Return here to avoid resetting the state to `HasVersion` + // We update the cache because ignored information (eg available beta if beta + // program is off) may have changed + *prev_cache = version_cache.clone(); + return event; } + + log::warn!("Received new version in downloaded state. Aborting download"); + + event } }; self.state = State::HasVersion { version_cache }; |
