fixed utf8 parse error with lossy conversion

This commit is contained in:
Nickiel12 2023-08-26 07:35:03 -07:00
parent 3faccc1b99
commit 3edf4aa95a

View file

@ -60,15 +60,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
} }
} }
match Command::new(args.hddtemp_executable.clone()).output() {
Ok(val) => val,
Err(e) => {
println!("Error running hddtemp at all: {}", e.to_string());
println!("hddtemp = {}", args.hddtemp_executable.clone());
return Ok(());
}
};
{ {
let mut drive_temps: Vec<String> = vec![]; let mut drive_temps: Vec<String> = vec![];
@ -82,13 +73,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
} }
}; };
let tmp = match std::str::from_utf8(&output.stdout) { let tmp = String::from_utf8_lossy(&output.stdout).into_owned();
Ok(val) => val,
Err(e) => {
println!("Error parsing hddtemp output: {}", e.to_string());
return Ok(());
}
}.to_string();
if !tmp.contains("sensor") { if !tmp.contains("sensor") {
drive_temps.push(tmp.replace("\n", "Not running as sudo?")); drive_temps.push(tmp.replace("\n", "Not running as sudo?"));