Skip to content

Commit

Permalink
Fix: correctly list the number of items to delete
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementNerma committed Jan 24, 2025
1 parent 03665e3 commit d2ee250
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 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.2.1"
version = "4.2.2"
authors = ["Clément Nerma <[email protected]>"]
edition = "2021"
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ pub fn empty(exclude_dirs: &[PathBuf]) -> Result<()> {

let items = list_deletable_fs_items(trash_dir)?;

warn!("> Deleting all {} items...", items.len());
warn!("> Deleting {} item(s) recursively...", items.len());

let pbr = ProgressBar::new(items.len().try_into().unwrap());

Expand Down
2 changes: 2 additions & 0 deletions src/fsutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,10 @@ pub fn are_on_same_fs(a: &Path, b: &Path) -> Result<bool> {

pub fn list_deletable_fs_items(path: &Path) -> Result<Vec<PathBuf>> {
WalkDir::new(path)
.min_depth(1)
.contents_first(true)
.into_iter()
.filter_entry(|entry| entry.depth() == 1 && entry.file_name() == TRASH_TRANSFER_DIRNAME)
.map(|entry| entry.map(|entry| entry.into_path()))
.collect::<Result<Vec<PathBuf>, _>>()
.context("Failed to read directory entry")
Expand Down

0 comments on commit d2ee250

Please sign in to comment.