Additional fix for double path generation bug present in the original grin-wallet code, test on Linux if it works

This commit is contained in:
Anynomouss
2025-04-04 14:37:30 +02:00
parent 37715f189f
commit 21188555c6
2 changed files with 9 additions and 9 deletions
+8 -8
View File
@@ -49,23 +49,23 @@ pub fn get_wallet_path(
create_path: bool, create_path: bool,
) -> Result<PathBuf, ConfigError> { ) -> Result<PathBuf, ConfigError> {
// Check if grin dir exists // Check if grin dir exists
let mut grin_path = match dirs::home_dir() { let mut wallet_path = match dirs::home_dir() {
Some(p) => p, Some(p) => p,
None => PathBuf::new(), None => PathBuf::new(),
}; };
grin_path.push(GRIN_HOME); wallet_path.push(GRIN_HOME);
grin_path.push(chain_type.shortname()); wallet_path.push(chain_type.shortname());
// Create if the default path doesn't exist // Create if the default path doesn't exist
if !grin_path.exists() && create_path { if !wallet_path.exists() && create_path {
fs::create_dir_all(grin_path.clone())?; fs::create_dir_all(wallet_path.clone())?;
} }
if !grin_path.exists() { if !wallet_path.exists() {
Err(ConfigError::PathNotFoundError(String::from( Err(ConfigError::PathNotFoundError(String::from(
grin_path.to_str().unwrap(), wallet_path.to_str().unwrap(),
))) )))
} else { } else {
Ok(grin_path) Ok(wallet_path)
} }
} }
+1 -1
View File
@@ -133,7 +133,7 @@ where
return Err(Error::Lifecycle(msg)); 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() { if config_file_name.exists() {
return Ok(()); return Ok(());
} }