1
Fork 0
mirror of https://github.com/RGBCube/dix synced 2025-07-28 04:07:46 +00:00

src/main.rs: cleanup closure size function

This commit is contained in:
Bloxx12 2025-05-04 19:03:07 +02:00
parent 8f0c40f9a9
commit 6295610028
No known key found for this signature in database

View file

@ -190,22 +190,20 @@ fn check_nix_available() -> bool {
}
fn get_closure_size(path: &std::path::Path) -> u64 {
let bytes = Command::new("nix")
Command::new("nix")
.arg("path-info")
.arg("--closure-size")
.arg(path.join("sw"))
.output();
if let Ok(size) = bytes {
let res = str::from_utf8(&size.stdout);
if let Ok(res) = res {
let res = res.split_whitespace().last();
if let Some(res) = res {
if let Ok(res) = res.parse::<u64>() {
return res / 1024 / 1024;
}
}
}
}
0
.output()
.ok()
.and_then(|output| {
str::from_utf8(&output.stdout)
.ok()?
.split_whitespace()
.last()?
.parse::<u64>()
.ok()
})
.map(|size| size / 1024 / 1024)
.unwrap_or(0)
}