@@ -17,6 +17,7 @@ use crate::app::{
17
17
#[ derive( Default ) ]
18
18
struct HwmonResults {
19
19
temperatures : Vec < TempHarvest > ,
20
+ num_hwmon : usize ,
20
21
}
21
22
22
23
/// Parses and reads temperatures that were in millidegree Celsius, and if successful, returns a temperature in Celsius.
@@ -94,6 +95,8 @@ fn get_from_hwmon(temp_type: &TemperatureType, filter: &Option<Filter>) -> Resul
94
95
// It's possible that there are dupes (represented by symlinks) - the easy
95
96
// way is to just substitute the parent directory and check if the hwmon
96
97
// variant exists already in a set.
98
+ //
99
+ // For more info, see https://github.com/giampaolo/psutil/pull/1822/files
97
100
if let Some ( child) = path. file_name ( ) {
98
101
let to_check_path = Path :: new ( "/sys/class/hwmon" ) . join ( child) ;
99
102
@@ -111,8 +114,11 @@ fn get_from_hwmon(temp_type: &TemperatureType, filter: &Option<Filter>) -> Resul
111
114
112
115
let mut dirs = HashSet :: default ( ) ;
113
116
add_hwmon ( & mut dirs) ;
117
+ let num_hwmon = dirs. len ( ) ;
114
118
add_coretemp ( & mut dirs) ;
115
119
120
+ // let mut thermal_types = HashSet::default();
121
+
116
122
// Note that none of this is async if we ever go back to it, but sysfs is in
117
123
// memory, so in theory none of this should block if we're slightly careful.
118
124
// Of note is that reading the temperature sensors of a device that has
@@ -236,7 +242,10 @@ fn get_from_hwmon(temp_type: &TemperatureType, filter: &Option<Filter>) -> Resul
236
242
}
237
243
}
238
244
239
- Ok ( HwmonResults { temperatures } )
245
+ Ok ( HwmonResults {
246
+ temperatures,
247
+ num_hwmon,
248
+ } )
240
249
}
241
250
242
251
/// Gets data from `/sys/class/thermal/thermal_zone*`. This should only be used if
@@ -294,7 +303,9 @@ pub fn get_temperature_data(
294
303
) -> Result < Option < Vec < TempHarvest > > > {
295
304
let mut results = get_from_hwmon ( temp_type, filter) . unwrap_or_default ( ) ;
296
305
297
- get_from_thermal_zone ( & mut results. temperatures , temp_type, filter) ;
306
+ if results. num_hwmon == 0 {
307
+ get_from_thermal_zone ( & mut results. temperatures , temp_type, filter) ;
308
+ }
298
309
299
310
#[ cfg( feature = "nvidia" ) ]
300
311
{
0 commit comments