Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sysinfo v0.33 return empty components list #1438

Closed
CongLuanTran opened this issue Dec 26, 2024 · 2 comments
Closed

Sysinfo v0.33 return empty components list #1438

CongLuanTran opened this issue Dec 26, 2024 · 2 comments
Labels

Comments

@CongLuanTran
Copy link
Contributor

This is my first bug report so if I make any mistake please guide me.

Describe the bug
OS: Arch Linux
Kernel: 6.12.6-arch1-1
Device: Asus VivoBook X415EA

I use the minimal example provided in the document with sysinfo 0.33 and the components list is empty. However the same code works if the crate is down graded to 0.32.1 and the result contains:

iwlwifi_1 temp1: 44°C (max: 44°C)
coretemp Core 1: 71°C (max: 71°C / critical: 100°C)
coretemp Core 0: 74°C (max: 74°C / critical: 100°C)
coretemp Core 2: 72°C (max: 72°C / critical: 100°C)
coretemp Core 3: 72°C (max: 72°C / critical: 100°C)
coretemp Package id 0: 74°C (max: 74°C / critical: 100°C)
nvme Composite INTEL SSDPEKNU512GZ temp1: 28.85°C (max: 28.85°C / critical: 79.85°C)
acpitz temp1: 55°C (max: 55°C)

Version 0.33 can partially work if I refresh the components list once more after it is created, but only contains:

temperature: 62°C (max: 62°C / critical: unknown)

To Reproduce
The minimal example from the document is:

use sysinfo::Components;

let components = Components::new_with_refreshed_list();
for component in &components {
    println!("{component:?}");
}

This code produces empty list for version 0.33 but works fine with version 0.32.1

The code that partial works for 0.33 is:

use sysinfo::Components;

let mut components = Components::new_with_refreshed_list();
components.refresh(false);
for component in &components {
    println!("{component:?}");
}
@CongLuanTran
Copy link
Contributor Author

I think I figured out the bug, it is the wrong logic when checking that the DirEntry is a file and not a directory in the method from_hwmon(). The current code is:

            if !entry.file_type().is_ok_and(|file_type| file_type.is_dir()) {
                continue;
            }

While the correct one should be:

            if !entry.file_type().is_ok_and(|file_type| !file_type.is_dir()) {
                continue;
            }

@GuillaumeGomez
Copy link
Owner

Fixed in #1439.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants