Skip to content

Commit

Permalink
fix: checking of valid path before starting, correct hover text for w…
Browse files Browse the repository at this point in the history
…indows
  • Loading branch information
Cyrix126 committed Dec 11, 2024
1 parent 4ebd48f commit 6ff16af
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
22 changes: 14 additions & 8 deletions src/app/panels/bottom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,10 @@ impl crate::app::App {
let path = match name {
ProcessName::Node => {
// check path of DB valid, empty valid.
if !Gupax::path_is_file(&self.state.node.path_db) {
return Err(format!("Error: {}", NODE_PATH_NOT_FILE));
if !self.state.node.path_db.is_empty()
&& !Gupax::path_is_file(&self.state.node.path_db)
{
return Err(format!("Error: {}", NODE_DB_DIR));
}
&self.state.gupax.node_path
}
Expand All @@ -587,13 +589,17 @@ impl crate::app::App {
}
};
// check path of binary except for XvB
if name != ProcessName::Xvb && !crate::components::update::check_binary_path(path, name) {
let msg_error = format!(
"{name} binary at the given PATH in the Gupaxx tab doesn't look like {name}! To fix: goto the [Gupaxx Advanced] tab, select [Open] and specify where {name} is located."
);
return Err(msg_error);
if name != ProcessName::Xvb {
if path.is_empty() {
return Err(name.msg_binary_path_empty().to_string());
}
if !Gupax::path_is_file(path) {
return Err(name.msg_binary_path_not_file().to_string());
}
if !crate::components::update::check_binary_path(path, name) {
return Err(name.msg_binary_path_invalid().to_string());
}
}

Ok(())
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ pub fn check_binary_path(path: &str, process: ProcessName) -> bool {
Ok(p) => p,
Err(_) => return false,
};
let path = match path.file_name() {
let filename = match path.file_name() {
Some(p) => p,
None => {
error!("Couldn't get {process} file name");
return false;
}
};
path == process.binary_name()
filename == process.binary_name()
}

//---------------------------------------------------------------------------------------------------- Update struct/impl
Expand Down
8 changes: 6 additions & 2 deletions src/utils/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,13 @@ pub const LIST_CLEAR: &str = "Clear all current values";
pub const NODE_ARGUMENTS: &str = r#"WARNING: Make sure to set [--zmq-pub <tcp://127.0.0.1:18081>] so that P2Pool can connect to it !"#;
pub const NODE_INPUT: &str = "Send a command to Node";
pub const NODE_PRUNNING: &str = "Reduce the database size to a third. Does not have any security/privacy impact.If you have enough storage, a full node is preferable to make the network even more decentralized.";
#[cfg(not(windows))]
pub const NODE_DB_PATH_EMPTY: &str =
"If the PATH of the DB is empty, the default ~/.bitmonero will be used.";
pub const NODE_DB_DIR: &str = "The PATH needs to be a correct path to a directory";
#[cfg(windows)]
pub const NODE_DB_PATH_EMPTY: &str =
r#"If the PATH of the DB is empty, the default C:\ProgramData\bitmonero will be used."#;
pub const NODE_DB_DIR: &str = "The DB path needs to be a correct path to a directory if not empty";
pub const NODE_SIMPLE: &str = r#"Use simple Node settings:
- Default Node settings"#;
pub const NODE_ADVANCED: &str = r#"Use advanced Node settings:
Expand All @@ -445,7 +449,7 @@ pub const NODE_ADVANCED: &str = r#"Use advanced Node settings:
- Log level setting
- Disable DNS checkpoint
- DNS blocking"#;
pub const GUPAX_PATH_NODE: &str = "The location of the DB for the Node: Both absolute and relative paths are accepted; A red [X] will appear if there is no directory found at the given path";
pub const GUPAX_PATH_NODE: &str = "The location of the Node binary: Both absolute and relative paths are accepted; A red [X] will appear if there is no directory found at the given path";
pub const NODE_PATH_OK: &str = "PATH for DB is valid.";
pub const NODE_PATH_NOT_FILE: &str = "Node binary not found at the given PATH in the Gupaxx tab! To fix: goto the [Gupaxx Advanced] tab, select [Open] and specify where NODE is located.";
pub const NODE_PATH_NOT_VALID: &str = "Node binary at the given PATH in the Gupaxx tab doesn't look like Node! To fix: goto the [Gupaxx Advanced] tab, select [Open] and specify where Node is located.";
Expand Down

0 comments on commit 6ff16af

Please sign in to comment.