diff --git a/common/config/src/lib.rs b/common/config/src/lib.rs index b9d179942a..48339be66b 100644 --- a/common/config/src/lib.rs +++ b/common/config/src/lib.rs @@ -12,12 +12,16 @@ pub trait NymConfig: Default + Serialize + DeserializeOwned { fn default_root_directory() -> PathBuf; // default, most probable, implementations; can be easily overridden where required - fn default_config_directory() -> PathBuf { - Self::default_root_directory().join("config") + fn default_config_directory(id: Option<&str>) -> PathBuf { + Self::default_root_directory() + .join(id.unwrap_or("")) + .join("config") } - fn default_data_directory() -> PathBuf { - Self::default_root_directory().join("data") + fn default_data_directory(id: Option<&str>) -> PathBuf { + Self::default_root_directory() + .join(id.unwrap_or("")) + .join("data") } fn root_directory(&self) -> PathBuf; @@ -35,9 +39,9 @@ pub trait NymConfig: Default + Serialize + DeserializeOwned { ) } - fn load_from_file(custom_location: Option) -> io::Result { + fn load_from_file(custom_location: Option, id: Option<&str>) -> io::Result { let config_contents = fs::read_to_string( - custom_location.unwrap_or(Self::default_config_directory().join("config.toml")), + custom_location.unwrap_or(Self::default_config_directory(id).join("config.toml")), )?; let parsing_result = toml::from_str(&config_contents)