summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authordatabase64128 <free122448@hotmail.com>2022-11-22 04:36:06 +0800
committerGitHub <noreply@github.com>2022-11-21 15:36:06 -0500
commita0eebf3acb686a0fb4e6c1d200800ee393a0a463 (patch)
tree235b7952633585d6076d9f9db0f654660d659301 /src
parent4f00434210a20109f4b9ca27c1b1856f376499b5 (diff)
bug: fix reading temperature from disabled devices (#911)
Diffstat (limited to 'src')
-rw-r--r--src/app/data_harvester/temperature/linux.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/app/data_harvester/temperature/linux.rs b/src/app/data_harvester/temperature/linux.rs
index 166af3db..e03dff23 100644
--- a/src/app/data_harvester/temperature/linux.rs
+++ b/src/app/data_harvester/temperature/linux.rs
@@ -161,11 +161,16 @@ fn get_from_hwmon(
if is_temp_filtered(filter, &name) {
let temp = if should_read_temp {
- let temp = fs::read_to_string(temp)?;
- let temp = temp.trim_end().parse::<f32>().map_err(|e| {
- crate::utils::error::BottomError::ConversionError(e.to_string())
- })?;
- temp / 1_000.0
+ if let Ok(temp) = fs::read_to_string(temp) {
+ let temp = temp.trim_end().parse::<f32>().map_err(|e| {
+ crate::utils::error::BottomError::ConversionError(e.to_string())
+ })?;
+ temp / 1_000.0
+ } else {
+ // For some devices (e.g. iwlwifi), this file becomes empty when the device
+ // is disabled. In this case we skip the device.
+ continue;
+ }
} else {
0.0
};