From a0eebf3acb686a0fb4e6c1d200800ee393a0a463 Mon Sep 17 00:00:00 2001 From: database64128 Date: Tue, 22 Nov 2022 04:36:06 +0800 Subject: [PATCH] bug: fix reading temperature from disabled devices (#911) --- src/app/data_harvester/temperature/linux.rs | 15 ++++++++++----- 1 file 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::().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::().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 };