Skip to content

Commit

Permalink
feat: use better disk names
Browse files Browse the repository at this point in the history
  • Loading branch information
lleyton committed Jul 6, 2024
1 parent 83c826b commit 1857f59
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ gnome-desktop = "0.4.2"
chrono-tz = "0.9.0"
paste = "1.0.15"
tempfile = "3.10.1"
lsblk = "0.2.4"
lsblk = "0.3.0"
# serde_ini = "0.2.0"
# serde-enum-str = "0.4.0"
const_format = "0.2.32"
Expand Down
12 changes: 9 additions & 3 deletions src/disks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,19 @@ pub fn detect_os() -> Vec<DiskInit> {
.into_iter()
.filter(lsblk::BlockDevice::is_disk)
.map(|disk| {
let model = disk
.sysfs()
.and_then(|p| std::fs::read_to_string(p.join("device").join("model")));
let ret = DiskInit {
disk_name: format!(
"{} ({})",
disk.label
.as_deref()
model
.as_ref()
.map(|s| s.trim())
.ok()
.or(disk.label.as_deref())
.or(disk.id.as_deref())
.map_or("".into(), |s| format!("{s} ")),
.map_or("".into(), |s| s),

Check warning

Code scanning / clippy

useless conversion to the same type: &str Warning

useless conversion to the same type: &str
disk.name,
)
.trim()
Expand Down

0 comments on commit 1857f59

Please sign in to comment.