diff options
| author | David Lönnhager <david.l@mullvad.net> | 2023-06-28 12:12:55 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2023-06-28 12:12:55 +0200 |
| commit | 83aaaca15a068b88744131bc97bd97ae4e817b79 (patch) | |
| tree | 681d5534afa444b076ed5997bf60f60ea43f5c5d | |
| parent | f65b20b10987e4a8c7fa3814414793422eb77da0 (diff) | |
| parent | d2ec165f31afdad1f6a16d1734d800411e61f133 (diff) | |
| download | mullvadvpn-83aaaca15a068b88744131bc97bd97ae4e817b79.tar.xz mullvadvpn-83aaaca15a068b88744131bc97bd97ae4e817b79.zip | |
Merge branch 'better-handle-404-in-device-removal-des-85'
| -rw-r--r-- | mullvad-setup/src/main.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/mullvad-setup/src/main.rs b/mullvad-setup/src/main.rs index 8cf6ad3778..118b572414 100644 --- a/mullvad-setup/src/main.rs +++ b/mullvad-setup/src/main.rs @@ -1,5 +1,5 @@ use clap::Parser; -use mullvad_api::{self, proxy::ApiConnectionMode}; +use mullvad_api::{self, proxy::ApiConnectionMode, DEVICE_NOT_FOUND}; use mullvad_management_interface::MullvadProxyClient; use mullvad_types::version::ParsedAppVersion; use std::{path::PathBuf, process, str::FromStr, time::Duration}; @@ -171,7 +171,8 @@ async fn remove_device() -> Result<(), Error> { ) .await, ); - retry_future_n( + + let device_removal = retry_future_n( move || proxy.remove(device.account_token.clone(), device.device.id.clone()), move |result| match result { Err(error) => error.is_network_error(), @@ -180,8 +181,16 @@ async fn remove_device() -> Result<(), Error> { constant_interval(KEY_RETRY_INTERVAL), KEY_RETRY_MAX_RETRIES, ) - .await - .map_err(Error::RemoveDeviceError)?; + .await; + + // `DEVICE_NOT_FOUND` is not considered to be an error in this context. + match device_removal { + Ok(_) => Ok(()), + Err(mullvad_api::rest::Error::ApiError(_status, code)) if code == DEVICE_NOT_FOUND => { + Ok(()) + } + Err(e) => Err(Error::RemoveDeviceError(e)), + }?; cacher .remove() |
