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