Repository: GuillaumeGomez/sysinfo (language: rust)

Issue:
Temperatures on Linux unavailable
A commit on April 7, 2024 causes temperatures on Linux to not be available.  The `temperature` command in `examples/simple.rs` no longer prints anything on commit [87c627c1ff07c6a43060c397bcb401e5d72d33e0](https://github.com/GuillaumeGomez/sysinfo/commit/87c627c1ff07c6a43060c397bcb401e5d72d33e0)  or later.



Discussion / hints:

Fix patch:
diff --git a/src/unix/linux/component.rs b/src/unix/linux/component.rs
index fc0b2fb72..ffa2099b8 100644
--- a/src/unix/linux/component.rs
+++ b/src/unix/linux/component.rs
@@ -374,16 +374,15 @@ impl ComponentsInner {
                     continue;
                 };
                 let entry = entry.path();
-                if !file_type.is_dir()
-                    || !entry
+                if !file_type.is_file()
+                    && entry
                         .file_name()
                         .and_then(|x| x.to_str())
                         .unwrap_or("")
                         .starts_with("hwmon")
                 {
-                    continue;
+                    ComponentInner::from_hwmon(&mut self.components, &entry);
                 }
-                ComponentInner::from_hwmon(&mut self.components, &entry);
             }
         }
     }


Test patch:
diff --git a/tests/components.rs b/tests/components.rs
new file mode 100644
index 000000000..27cadf3e9
--- /dev/null
+++ b/tests/components.rs
@@ -0,0 +1,17 @@
+// Take a look at the license at the top of the repository in the LICENSE file.
+
+#[test]
+fn test_components() {
+    use std::env::var;
+
+    let mut c = sysinfo::Components::new();
+    assert!(c.is_empty());
+
+    // Unfortunately, we can't get components in the CI...
+    if !sysinfo::IS_SUPPORTED_SYSTEM || cfg!(windows) || var("CI").is_ok() {
+        return;
+    }
+
+    c.refresh_list();
+    assert!(!c.is_empty());
+}