Open cafkafk opened 1 week ago
Hmmmmm. There's likely not a lot I can do about that -- it's probably inside the directory traversal crate I'm using, because starting at /
will find a lot of things that aren't really directories. Like much of /dev
, all of /sys
on Linux, /proc
, etc. (I wouldn't recommend applying the program to /dev
!)
I could add a warning if you pass the literal path /
, I suppose.
Just out of curiosity, I decided to give this a quick look, and got stuck on a bunch of varying os errors (3, 13, 22).
index 1394bb8..03b99cc 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -70,8 +70,10 @@ fn main() -> anyhow::Result<()> {
let mut paths: BTreeMap<u64, Vec<PathBuf>> = BTreeMap::new();
for root in &args.roots {
for entry in WalkDir::new(root) {
- let entry = entry?;
- let meta = entry.metadata()?;
+ let Ok(entry) = entry else {
+ continue;
+ };
+ let Ok(meta) = entry.metadata() else {continue;};
if meta.is_file() && (meta.len() > 0 || args.empty) {
paths.entry(meta.len())
.or_default()
The above isn't really ideal error handling, but just skipping those did let the program finish. I suppose one approach could be to do like rg
and just skip --- but report --- filesystem failures and their location (e.g. see rg hello /proc
).
I
cargo run
'ed this on/
, and I keep gettingIt also happens on
./target/release/drupes /
, but not other dirs like e.g.~/
.(I know this is a "toy" project... but hey, here's something to do if you get bored)