Skip to content

Commit

Permalink
Don't display useless size for trashed directories
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementNerma committed Sep 24, 2024
1 parent 9898cd2 commit 60aa412
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "trasher"
version = "4.0.1"
version = "4.0.2"
authors = ["Clément Nerma <[email protected]>"]
edition = "2021"
license = "Apache-2.0"
Expand Down
30 changes: 17 additions & 13 deletions src/fsutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,24 +408,28 @@ pub fn table_for_items(items: &[TrashedItem]) -> Table {
let mt = fs::metadata(item.complete_trash_item_path());

table.add_row(vec![
match &mt {
Ok(mt) => {
mt.as_ref()
.map(|mt| {
if mt.file_type().is_file() {
"File".to_owned()
"File"
} else if mt.file_type().is_dir() {
"Directory".to_owned()
"Directory"
} else {
"<Unknown>".to_owned()
"<Unknown>"
}
}

Err(err) => format!("ERROR: {err}"),
},
.to_owned()
})
.unwrap_or_else(|err| format!("ERROR: {err}")),
filename.clone(),
match &mt {
Ok(mt) => human_readable_size(mt.len()),
Err(_) => "ERROR".to_owned(),
},
mt.as_ref()
.map(|mt| {
if mt.file_type().is_file() {
human_readable_size(mt.len())
} else {
String::new()
}
})
.unwrap_or_else(|_| "ERROR".to_owned()),
data.compute_id(),
Zoned::try_from(*datetime)
.and_then(|date| jiff::fmt::rfc2822::to_string(&date))
Expand Down

0 comments on commit 60aa412

Please sign in to comment.