disk: fix serializing quotes in strings

This commit is contained in:
hinto-janaiyo 2022-12-16 22:38:46 -05:00
parent 3ac0b98802
commit 166c89a8d1
No known key found for this signature in database
GPG key ID: B1C5A64B80691E45
3 changed files with 28 additions and 9 deletions

View file

@ -348,16 +348,25 @@ impl Node {
let mut vec = Vec::with_capacity(size);
for (key, values) in nodes.iter() {
let ip = match values.get("ip") {
Some(ip) => match ip.as_str() {
Some(ip) => ip.to_string(),
None => { error!("Node | [None] at [ip] parse"); return Err(TomlError::Parse("[None] at [ip] parse")) },
},
None => { error!("Node | [None] at [ip] parse"); return Err(TomlError::Parse("[None] at [ip] parse")) },
};
let rpc = match values.get("rpc") {
Some(rpc) => match rpc.as_str() {
Some(rpc) => rpc.to_string(),
None => { error!("Node | [None] at [rpc] parse"); return Err(TomlError::Parse("[None] at [rpc] parse")) },
},
None => { error!("Node | [None] at [rpc] parse"); return Err(TomlError::Parse("[None] at [rpc] parse")) },
};
let zmq = match values.get("zmq") {
Some(zmq) => match zmq.as_str() {
Some(zmq) => zmq.to_string(),
None => { error!("Node | [None] at [zmq] parse"); return Err(TomlError::Parse("[None] at [zmq] parse")) },
},
None => { error!("Node | [None] at [zmq] parse"); return Err(TomlError::Parse("[None] at [zmq] parse")) },
};
let node = Node {
ip,
@ -470,18 +479,28 @@ impl Pool {
};
let size = pools.keys().len();
let mut vec = Vec::with_capacity(size);
// We have to do [.as_str()] -> [.to_string()] to get rid of the \"...\" that gets added on.
for (key, values) in pools.iter() {
let rig = match values.get("rig") {
Some(rig) => match rig.as_str() {
Some(rig) => rig.to_string(),
None => { error!("Pool | [None] at [rig] parse"); return Err(TomlError::Parse("[None] at [rig] parse")) },
},
None => { error!("Pool | [None] at [rig] parse"); return Err(TomlError::Parse("[None] at [rig] parse")) },
};
let ip = match values.get("ip") {
Some(ip) => match ip.as_str() {
Some(ip) => ip.to_string(),
None => { error!("Pool | [None] at [ip] parse"); return Err(TomlError::Parse("[None] at [ip] parse")) },
},
None => { error!("Pool | [None] at [ip] parse"); return Err(TomlError::Parse("[None] at [ip] parse")) },
};
let port = match values.get("port") {
Some(port) => match port.as_str() {
Some(port) => port.to_string(),
None => { error!("Pool | [None] at [port] parse"); return Err(TomlError::Parse("[None] at [port] parse")) },
},
None => { error!("Pool | [None] at [port] parse"); return Err(TomlError::Parse("[None] at [port] parse")) },
};
let pool = Pool {
rig,

View file

@ -1308,7 +1308,7 @@ impl eframe::App for App {
ui.group(|ui| {
ui.set_enabled(self.diff);
let width = width / 2.0;
if key.is_r() && !wants_input || ui.add_sized([width, height], Button::new("Reset")).on_hover_text("Reset changes").clicked() {
if key.is_r() && !wants_input && self.diff || ui.add_sized([width, height], Button::new("Reset")).on_hover_text("Reset changes").clicked() {
let og = self.og.lock().unwrap().clone();
self.state.gupax = og.gupax;
self.state.p2pool = og.p2pool;
@ -1316,7 +1316,7 @@ impl eframe::App for App {
self.node_vec = self.og_node_vec.clone();
self.pool_vec = self.og_pool_vec.clone();
}
if key.is_s() && !wants_input || ui.add_sized([width, height], Button::new("Save")).on_hover_text("Save changes").clicked() {
if key.is_s() && !wants_input && self.diff || ui.add_sized([width, height], Button::new("Save")).on_hover_text("Save changes").clicked() {
match State::save(&mut self.state, &self.state_path) {
Ok(_) => {
let mut og = self.og.lock().unwrap();

View file

@ -165,7 +165,7 @@ impl SudoState {
},
}
}
if let Err(e) = sudo.kill() { error!("Sudo | Kill error: {}", e); }
if let Err(e) = sudo.kill() { warn!("Sudo | Kill error (it probably already exited): {}", e); }
if state.lock().unwrap().success {
match state.lock().unwrap().signal {
ProcessSignal::Restart => crate::helper::Helper::restart_xmrig(&helper, &xmrig, &path, Arc::clone(&state)),