From b8ab07020c4495bb098a925ac09f5277031a150f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Tue, 26 Mar 2024 14:26:45 +0000 Subject: [PATCH] fixed eda61b57dc8d349a9b0af70cbd02743eba1e10bf --- .../ip-packet-router/src/config/helpers.rs | 5 +++-- .../network-requester/src/config/helpers.rs | 19 +++++++++++-------- .../src/config/old_config_v1_1_33.rs | 1 + 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/service-providers/ip-packet-router/src/config/helpers.rs b/service-providers/ip-packet-router/src/config/helpers.rs index 5c965e8951..e6abda1d98 100644 --- a/service-providers/ip-packet-router/src/config/helpers.rs +++ b/service-providers/ip-packet-router/src/config/helpers.rs @@ -5,6 +5,7 @@ use crate::config::default_config_filepath; use crate::config::old_config_v1::ConfigV1; use crate::error::IpPacketRouterError; use log::{info, trace}; +use nym_client_core::cli_helpers::CliClientConfig; use nym_client_core::client::base_client::storage::migration_helpers::v1_1_33; use std::path::Path; @@ -12,7 +13,7 @@ async fn try_upgrade_v1_config>( config_path: P, ) -> Result { // explicitly load it as v1 (which is incompatible with the current one) - let Ok(old_config) = ConfigV1::read_from_toml_file(config_path) else { + let Ok(old_config) = ConfigV1::read_from_toml_file(config_path.as_ref()) else { // if we failed to load it, there might have been nothing to upgrade // or maybe it was an even older file. in either way. just ignore it and carry on with our day return Ok(false); @@ -30,7 +31,7 @@ async fn try_upgrade_v1_config>( ) .await?; - updated.save_to_default_location()?; + updated.save_to(config_path)?; Ok(true) } diff --git a/service-providers/network-requester/src/config/helpers.rs b/service-providers/network-requester/src/config/helpers.rs index 5ef027d078..e03281fa01 100644 --- a/service-providers/network-requester/src/config/helpers.rs +++ b/service-providers/network-requester/src/config/helpers.rs @@ -8,6 +8,7 @@ use crate::config::old_config_v1_1_20_2::ConfigV1_1_20_2; use crate::config::old_config_v1_1_33::ConfigV1_1_33; use crate::error::NetworkRequesterError; use log::{info, trace}; +use nym_client_core::cli_helpers::CliClientConfig; use nym_client_core::client::base_client::storage::migration_helpers::v1_1_33; use std::path::Path; @@ -18,7 +19,7 @@ async fn try_upgrade_v1_1_13_config>( use nym_config::legacy_helpers::nym_config::MigrationNymConfig; // explicitly load it as v1.1.13 (which is incompatible with the next step, i.e. 1.1.19) - let Ok(old_config) = OldConfigV1_1_13::load_from_filepath(config_path) else { + let Ok(old_config) = OldConfigV1_1_13::load_from_filepath(config_path.as_ref()) else { // if we failed to load it, there might have been nothing to upgrade // or maybe it was an even older file. in either way. just ignore it and carry on with our day return Ok(false); @@ -39,7 +40,7 @@ async fn try_upgrade_v1_1_13_config>( ) .await?; - updated.save_to_default_location()?; + updated.save_to(config_path)?; Ok(true) } @@ -50,7 +51,7 @@ async fn try_upgrade_v1_1_20_config>( use nym_config::legacy_helpers::nym_config::MigrationNymConfig; // explicitly load it as v1.1.20 (which is incompatible with the current one, i.e. +1.1.21) - let Ok(old_config) = ConfigV1_1_20::load_from_filepath(config_path) else { + let Ok(old_config) = ConfigV1_1_20::load_from_filepath(config_path.as_ref()) else { // if we failed to load it, there might have been nothing to upgrade // or maybe it was an even older file. in either way. just ignore it and carry on with our day return Ok(false); @@ -71,7 +72,7 @@ async fn try_upgrade_v1_1_20_config>( ) .await?; - updated.save_to_default_location()?; + updated.save_to(config_path)?; Ok(true) } @@ -81,7 +82,7 @@ async fn try_upgrade_v1_1_20_2_config>( trace!("Trying to load as v1.1.20_2 config"); // explicitly load it as v1.1.20_2 (which is incompatible with the current one, i.e. +1.1.21) - let Ok(old_config) = ConfigV1_1_20_2::read_from_toml_file(config_path) else { + let Ok(old_config) = ConfigV1_1_20_2::read_from_toml_file(config_path.as_ref()) else { // if we failed to load it, there might have been nothing to upgrade // or maybe it was an even older file. in either way. just ignore it and carry on with our day return Ok(false); @@ -100,15 +101,17 @@ async fn try_upgrade_v1_1_20_2_config>( ) .await?; - updated.save_to_default_location()?; + updated.save_to(config_path)?; Ok(true) } async fn try_upgrade_v1_1_33_config>( config_path: P, ) -> Result { + trace!("Trying to load as v1.1.33 config"); + // explicitly load it as v1.1.33 (which is incompatible with the current one, i.e. +1.1.34) - let Ok(old_config) = ConfigV1_1_33::read_from_toml_file(config_path) else { + let Ok(old_config) = ConfigV1_1_33::read_from_toml_file(config_path.as_ref()) else { // if we failed to load it, there might have been nothing to upgrade // or maybe it was an even older file. in either way. just ignore it and carry on with our day return Ok(false); @@ -126,7 +129,7 @@ async fn try_upgrade_v1_1_33_config>( ) .await?; - updated.save_to_default_location()?; + updated.save_to(config_path)?; Ok(true) } diff --git a/service-providers/network-requester/src/config/old_config_v1_1_33.rs b/service-providers/network-requester/src/config/old_config_v1_1_33.rs index e211256643..b3089b036f 100644 --- a/service-providers/network-requester/src/config/old_config_v1_1_33.rs +++ b/service-providers/network-requester/src/config/old_config_v1_1_33.rs @@ -36,6 +36,7 @@ pub struct NetworkRequesterPathsV1_1_33 { #[derive(Debug, Deserialize, PartialEq, Serialize)] #[serde(deny_unknown_fields)] pub struct ConfigV1_1_33 { + #[serde(flatten)] pub base: BaseConfigV1_1_33, #[serde(default)]