mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-10-17 15:21:39 +02:00
Smart config loading, initializing, normal and template works, do some last tests on Linux
This commit is contained in:
+9
-17
@@ -188,9 +188,12 @@ pub fn initial_setup_wallet(
|
|||||||
create_path: bool,
|
create_path: bool,
|
||||||
) -> Result<GlobalWalletConfig, ConfigError> {
|
) -> Result<GlobalWalletConfig, ConfigError> {
|
||||||
if create_path {
|
if create_path {
|
||||||
if let Some(path_fixed) = &data_path {
|
if let Some(p) = data_path.clone() {
|
||||||
// Fix for a bug in the rust fs package to handle "\" in paths
|
// Fix for a bug in the rust fs package to handle "\" in paths
|
||||||
fs::create_dir_all(&path_fixed)?;
|
let p_fix = p.clone();
|
||||||
|
let p_fix = p_fix.to_str().unwrap().to_owned().replace("\\", "/");
|
||||||
|
let p_fix = PathBuf::from(p_fix);
|
||||||
|
fs::create_dir_all(p_fix)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,26 +352,15 @@ impl GlobalWalletConfig {
|
|||||||
|
|
||||||
/// Update paths
|
/// Update paths
|
||||||
pub fn update_paths(&mut self, wallet_home: &PathBuf, node_home: &PathBuf) {
|
pub fn update_paths(&mut self, wallet_home: &PathBuf, node_home: &PathBuf) {
|
||||||
// Below code formats the path to use "\\" in line with all paths in the toml file
|
let mut data_file_dir = wallet_home.clone();
|
||||||
let wallet_home_formatted = wallet_home.clone().clone();
|
|
||||||
let wallet_home_formatted = wallet_home_formatted
|
|
||||||
.to_str()
|
|
||||||
.unwrap()
|
|
||||||
.to_owned()
|
|
||||||
.replace("/", "\\");
|
|
||||||
let wallet_home_formatted = PathBuf::from(wallet_home_formatted);
|
|
||||||
// Clone paths for editing
|
|
||||||
let mut data_file_dir = wallet_home_formatted.clone();
|
|
||||||
let mut node_secret_path = node_home.clone();
|
let mut node_secret_path = node_home.clone();
|
||||||
let mut secret_path = wallet_home_formatted.clone();
|
let mut secret_path = wallet_home.clone();
|
||||||
let mut log_path = wallet_home_formatted.clone();
|
let mut log_path = wallet_home.clone();
|
||||||
let tor_path = wallet_home_formatted.clone();
|
let tor_path = wallet_home.clone();
|
||||||
// Push the respective directories to get the final paths
|
|
||||||
node_secret_path.push(API_SECRET_FILE_NAME);
|
node_secret_path.push(API_SECRET_FILE_NAME);
|
||||||
data_file_dir.push(GRIN_WALLET_DIR);
|
data_file_dir.push(GRIN_WALLET_DIR);
|
||||||
secret_path.push(OWNER_API_SECRET_FILE_NAME);
|
secret_path.push(OWNER_API_SECRET_FILE_NAME);
|
||||||
log_path.push(WALLET_LOG_FILE_NAME);
|
log_path.push(WALLET_LOG_FILE_NAME);
|
||||||
// Update the config variabless with the update paths
|
|
||||||
self.members.as_mut().unwrap().wallet.data_file_dir =
|
self.members.as_mut().unwrap().wallet.data_file_dir =
|
||||||
data_file_dir.to_str().unwrap().to_owned();
|
data_file_dir.to_str().unwrap().to_owned();
|
||||||
self.members.as_mut().unwrap().wallet.node_api_secret_path =
|
self.members.as_mut().unwrap().wallet.node_api_secret_path =
|
||||||
|
|||||||
@@ -166,16 +166,8 @@ impl WalletSeed {
|
|||||||
// create directory if it doesn't exist
|
// create directory if it doesn't exist
|
||||||
fs::create_dir_all(data_file_dir).map_err(|_| Error::IO)?;
|
fs::create_dir_all(data_file_dir).map_err(|_| Error::IO)?;
|
||||||
|
|
||||||
// Format data path properly
|
let seed_file_path = &format!("{}{}{}", data_file_dir, MAIN_SEPARATOR, SEED_FILE,);
|
||||||
let data_file_dir_formatted = data_file_dir;
|
|
||||||
let data_file_dir_formatted =
|
|
||||||
data_file_dir_formatted.replace("/", &MAIN_SEPARATOR.to_string());
|
|
||||||
let data_file_dir_formatted =
|
|
||||||
data_file_dir_formatted.replace("\\", &MAIN_SEPARATOR.to_string());
|
|
||||||
let seed_file_path =
|
|
||||||
&format!("{}{}{}", data_file_dir_formatted, MAIN_SEPARATOR, SEED_FILE,);
|
|
||||||
|
|
||||||
// Inform the user the seed has been generated
|
|
||||||
warn!("Generating wallet seed file at: {}", seed_file_path);
|
warn!("Generating wallet seed file at: {}", seed_file_path);
|
||||||
let exists = WalletSeed::seed_file_exists(data_file_dir)?;
|
let exists = WalletSeed::seed_file_exists(data_file_dir)?;
|
||||||
if exists && !test_mode {
|
if exists && !test_mode {
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ fn real_main() -> i32 {
|
|||||||
let res = args.value_of("top_level_dir");
|
let res = args.value_of("top_level_dir");
|
||||||
match res {
|
match res {
|
||||||
Some(d) => {
|
Some(d) => {
|
||||||
let d = d.to_owned().replace("\\", "/"); // Fix for path since backslashes in paths do not work on Linux
|
let d = d.to_owned().replace("/", "\\"); // Fix for fs to work with paths on Linux
|
||||||
current_dir = Some(PathBuf::from(d));
|
current_dir = Some(PathBuf::from(d));
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
|
|||||||
Reference in New Issue
Block a user