Skip to content

Commit 250fd83

Browse files
committed
Fix slow deletion on windows
- The stdlib function `std::fs::remove_dir_all` is currently extremely slow for large directory trees on windows - Replaced the std function with the crate `remove_dir_all` to fix this - Bump version to `0.4.1`
1 parent 2486c0c commit 250fd83

File tree

4 files changed

+103
-5
lines changed

4 files changed

+103
-5
lines changed

Cargo.lock

Lines changed: 94 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cargo-clean-all"
3-
version = "0.4.0"
3+
version = "0.4.1"
44
authors = ["Daniel M <danielm-github@dnml.de>"]
55
license = "MIT"
66
repository = "https://github.com/dnlmlr/cargo-clean-all"
@@ -17,3 +17,4 @@ bytefmt = "0.1.7"
1717
clap = { version = "3.1.2", features = ["derive"] }
1818
crossbeam-channel = "0.5.2"
1919
num_cpus = "1.13.1"
20+
remove_dir_all = "0.7.0"

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,9 @@ cargo clean-all --threads [number of threads]
6666
| Keep target dirs with a last modified treshold | yes | no |
6767
| Ask before cleaning | yes | no |
6868
| Clean only `release`, `debug` or `docs` | no (not yet) | yes |
69-
| Speed (non scientific, cleaning my home dir) | 15 sec | 24 sec |
69+
| Real `cargo clean` command under the hood | no | yes |
70+
71+
Note that `cargo-clean-recursive` uses the actual `cargo clean` command under the hood instead of
72+
simply deleting the target directories. This gives makes the cleaning work exactly as intended by
73+
the installed version of cargo, which can certainly be desirable in some cases.
74+

src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use clap::Parser;
22
use crossbeam_channel::Sender;
33
use std::{
4-
fs,
54
io::{stdin, stdout, Write},
65
path::{Path, PathBuf},
76
time::SystemTime,
@@ -125,7 +124,7 @@ fn main() {
125124

126125
projects
127126
.iter()
128-
.for_each(|p| fs::remove_dir_all(&p.project_path.join("target")).unwrap());
127+
.for_each(|p| remove_dir_all::remove_dir_all(&p.project_path.join("target")).unwrap());
129128

130129
println!("Done!");
131130
}

0 commit comments

Comments
 (0)