From 21188555c6b2b3f4ad5d8b61b73b1479d12bb53a Mon Sep 17 00:00:00 2001 From: Anynomouss Date: Fri, 4 Apr 2025 14:37:30 +0200 Subject: [PATCH] Additional fix for double path generation bug present in the original grin-wallet code, test on Linux if it works --- config/src/config.rs | 16 ++++++++-------- impls/src/lifecycle/default.rs | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config/src/config.rs b/config/src/config.rs index 1ceaef6..167b0ca 100644 --- a/config/src/config.rs +++ b/config/src/config.rs @@ -49,23 +49,23 @@ pub fn get_wallet_path( create_path: bool, ) -> Result { // Check if grin dir exists - let mut grin_path = match dirs::home_dir() { + let mut wallet_path = match dirs::home_dir() { Some(p) => p, None => PathBuf::new(), }; - grin_path.push(GRIN_HOME); - grin_path.push(chain_type.shortname()); + wallet_path.push(GRIN_HOME); + wallet_path.push(chain_type.shortname()); // Create if the default path doesn't exist - if !grin_path.exists() && create_path { - fs::create_dir_all(grin_path.clone())?; + if !wallet_path.exists() && create_path { + fs::create_dir_all(wallet_path.clone())?; } - if !grin_path.exists() { + if !wallet_path.exists() { Err(ConfigError::PathNotFoundError(String::from( - grin_path.to_str().unwrap(), + wallet_path.to_str().unwrap(), ))) } else { - Ok(grin_path) + Ok(wallet_path) } } diff --git a/impls/src/lifecycle/default.rs b/impls/src/lifecycle/default.rs index a50b470..805bda2 100644 --- a/impls/src/lifecycle/default.rs +++ b/impls/src/lifecycle/default.rs @@ -133,7 +133,7 @@ where return Err(Error::Lifecycle(msg)); } - // If config exists but the datadir not yet exists, create data dir return ok + // If config exists but the datadir return ok if config_file_name.exists() { return Ok(()); }