1
Fork 0
mirror of https://github.com/RGBCube/dix synced 2025-07-28 12:17:45 +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 { fn get_closure_size(path: &std::path::Path) -> u64 {
let bytes = Command::new("nix") Command::new("nix")
.arg("path-info") .arg("path-info")
.arg("--closure-size") .arg("--closure-size")
.arg(path.join("sw")) .arg(path.join("sw"))
.output(); .output()
.ok()
if let Ok(size) = bytes { .and_then(|output| {
let res = str::from_utf8(&size.stdout); str::from_utf8(&output.stdout)
if let Ok(res) = res { .ok()?
let res = res.split_whitespace().last(); .split_whitespace()
if let Some(res) = res { .last()?
if let Ok(res) = res.parse::<u64>() { .parse::<u64>()
return res / 1024 / 1024; .ok()
} })
} .map(|size| size / 1024 / 1024)
} .unwrap_or(0)
}
0
} }