Skip to content

Commit 4043391

Browse files
committed
machine-id
1 parent d870f10 commit 4043391

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/bencher_fingerprint/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ uuid.workspace = true
1111

1212
[target.'cfg(target_os = "windows")'.dependencies]
1313
uuid.workspace = true
14-
windows = { version = "0.60", features = ["System_Profile"] }
14+
windows = { version = "0.60", features = [
15+
"System_Profile_SystemManufacturers",
16+
] }
1517

1618
[lints]
1719
workspace = true

lib/bencher_fingerprint/src/linux.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ const HEX_BASE: u32 = 16;
44

55
impl crate::Fingerprint {
66
pub fn new() -> Option<Self> {
7-
fs::read_to_string("/etc/machine-id")
8-
.ok()
9-
.and_then(|id| u128::from_str_radix(&id, HEX_BASE).ok())
7+
parse_machine_id("/var/lib/dbus/machine-id")
8+
.or_else(|| parse_machine_id("/etc/machine-id"))
109
.map(Self)
1110
}
1211
}
12+
13+
fn parse_machine_id(path: &str) -> Option<u128> {
14+
fs::read_to_string(path)
15+
.ok()
16+
.and_then(|id| u128::from_str_radix(id.trim(), HEX_BASE).ok())
17+
}

0 commit comments

Comments
 (0)