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:
parent
8f0c40f9a9
commit
6295610028
1 changed files with 13 additions and 15 deletions
28
src/main.rs
28
src/main.rs
|
@ -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
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue