fix(about): add fallback for hardware model and processor
This commit is contained in:
parent
f3456ffc18
commit
bd7fc2a2f2
2 changed files with 10 additions and 1 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -8432,7 +8432,7 @@ version = "0.1.10"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0978bf7171b3d90bac376700cb56d606feb40f251a475a5d6634613564460b22"
|
||||
dependencies = [
|
||||
"windows-sys 0.48.0",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
|||
|
|
@ -146,6 +146,9 @@ pub fn hardware_model(bump: &Bump, hardware_model: &mut String) {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// simple fallback to sysinfo if DMI information is not available
|
||||
hardware_model.push_str(&sysinfo::Product::name().unwrap_or("".to_string()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -186,6 +189,12 @@ pub fn processor_name(bump: &Bump, name: &mut String) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fallback to sysinfo if /proc/cpuinfo is not present
|
||||
let s = sysinfo::System::new_with_specifics(
|
||||
sysinfo::RefreshKind::nothing().with_cpu(sysinfo::CpuRefreshKind::everything()),
|
||||
);
|
||||
name.push_str(s.cpus().into_iter().nth(0).unwrap().brand());
|
||||
}
|
||||
|
||||
pub fn read_to_string<'a, P: AsRef<OsStr>>(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue