main: update absolute paths before starting processes

Some situations won't update the path and so starting processes
didn't do anything and failed, this makes sure we have a valid
path before starting.
This commit is contained in:
hinto-janaiyo 2022-12-30 19:27:47 -05:00
parent 04d270b37f
commit e42e776f00
No known key found for this signature in database
GPG key ID: B1C5A64B80691E45
3 changed files with 17 additions and 7 deletions

View file

@ -2,6 +2,7 @@
## Fixes
* macOS: Added warning (and solution) if `Gupax/P2Pool/XMRig` were quarantined by [`Gatekeeper`](https://support.apple.com/en-us/HT202491)
* P2Pool/XMRig: Added a red `Start` button on errors (bad PATH, invalid file, etc) and a solution in the tooltip
* P2Pool/XMRig: Fixed processes sometimes not starting after entering a custom PATH
* P2Pool: Fixed custom node selection sometimes using old values after save
* Miscellaneous UI changes and fixes

View file

@ -170,6 +170,12 @@ impl State {
}
}
pub fn update_absolute_path(&mut self) -> Result<(), TomlError> {
self.gupax.absolute_p2pool_path = into_absolute_path(self.gupax.p2pool_path.clone())?;
self.gupax.absolute_xmrig_path = into_absolute_path(self.gupax.xmrig_path.clone())?;
Ok(())
}
// Convert [&str] to [State]
pub fn from_str(string: &str) -> Result<Self, TomlError> {
match toml::de::from_str(string) {

View file

@ -1455,6 +1455,8 @@ impl eframe::App for App {
ui.set_enabled(ui_enabled);
let color = if ui_enabled { GREEN } else { RED };
if (ui_enabled && key.is_up() && !wants_input) || ui.add_sized([width, height], Button::new(RichText::new("").color(color))).on_hover_text("Start P2Pool").on_disabled_hover_text(text).clicked() {
self.og.lock().unwrap().update_absolute_path();
self.state.update_absolute_path(); // The above checks make sure this can unwrap safely, probably should handle it though.
Helper::start_p2pool(&self.helper, &self.state.p2pool, &self.state.gupax.absolute_p2pool_path);
}
}
@ -1515,16 +1517,17 @@ impl eframe::App for App {
}
ui.set_enabled(ui_enabled);
let color = if ui_enabled { GREEN } else { RED };
#[cfg(target_os = "windows")]
if (ui_enabled && key.is_up() && !wants_input) || ui.add_sized([width, height], Button::new(RichText::new("").color(color))).on_hover_text("Start XMRig").on_disabled_hover_text(text).clicked() {
self.og.lock().unwrap().update_absolute_path();
self.state.update_absolute_path(); // The above checks make sure this can unwrap safely, probably should handle it though.
if cfg!(windows) {
Helper::start_xmrig(&self.helper, &self.state.xmrig, &self.state.gupax.absolute_xmrig_path, Arc::clone(&self.sudo));
}
#[cfg(target_family = "unix")]
if (ui_enabled && key.is_up() && !wants_input) || ui.add_sized([width, height], Button::new(RichText::new("").color(color))).on_hover_text("Start XMRig").on_disabled_hover_text(text).clicked() {
} else if cfg!(unix) {
self.sudo.lock().unwrap().signal = ProcessSignal::Start;
self.error_state.ask_sudo(&self.sudo);
}
}
}
});
},
_ => (),