inv: Prevent non-files from displaying file size

Maybe for folders I could later add a folder size but the method I'm
using to calculate file sizes doesn't work with folders, so yeah.
This commit is contained in:
Lux Aliaga 2022-09-18 00:35:50 -03:00
parent d11a200d6f
commit d24727d301
Signed by: lux
GPG Key ID: B56C805968637437
1 changed files with 10 additions and 6 deletions

View File

@ -117,7 +117,7 @@ pub fn list(slot: &str, dir: &str) {
let file = file.unwrap().path();
println!(
" - [{}] {} ({})",
" - [{}] {}{}",
if file.clone().is_dir() {
format!("D").blue()
} else if file.clone().is_symlink() {
@ -131,10 +131,14 @@ pub fn list(slot: &str, dir: &str) {
.to_os_string()
.into_string()
.unwrap(),
format!(
"{}B",
SizeFormatterBinary::new(file.clone().metadata().unwrap().len())
)
if file.clone().is_file() {
format!(
" ({}B)",
SizeFormatterBinary::new(file.clone().metadata().unwrap().len())
)
} else {
format!("")
}
);
}
}
@ -182,6 +186,6 @@ fn create_slots() {
println!(
"🎉 {}",
format!("Vento has been succesfully initialized!").green()
format!("Vento has been succesfully initialized!").green()
);
}