From 94f5ef822af9faf04a0489739d0806ab00186aa1 Mon Sep 17 00:00:00 2001 From: Dinko Korunic Date: Fri, 3 Nov 2023 08:29:08 +0100 Subject: [PATCH] Update deps. Add fd limit raise. Handle fatal dir scan I/O errors. --- Cargo.toml | 11 ++++++----- src/main.rs | 11 +++++++++++ src/walk.rs | 5 +++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 66e95d2..57b18c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "findlargedir" -version = "0.5.7" +version = "0.6.0" authors = ["Dinko Korunic "] categories = ["command-line-utilities"] description = "find all blackhole directories with a huge amount of filesystem entries in a flat structure" @@ -12,20 +12,21 @@ edition = "2021" [dependencies] jwalk = "0.8.1" -rayon = "1.7.0" +rayon = "1.8.0" num_cpus = "1.16.0" -tempfile = "3.8.0" +tempfile = "3.8.1" anyhow = "1.0.75" human_format = "1.0.3" human_bytes = { version = "0.4.3", features = ["fast"] } humantime = "2.1.0" -clap = { version = "4.4.3", features = ["derive"] } +clap = { version = "4.4.7", features = ["derive"] } ctrlc = { version = "3.4.1", features = ["termination"] } rm_rf = "0.6.2" ansi_term = "0.12.1" fs-err = "2.9.0" -indicatif = { version = "0.17.6", features = ["rayon"] } +indicatif = { version = "0.17.7", features = ["rayon"] } cfg-if = "1.0" +fdlimit = "0.2.1" [target.'cfg(all(target_os = "linux", target_arch = "x86_64"))'.dependencies] mimalloc = { version = "0.1.39", default-features = false } diff --git a/src/main.rs b/src/main.rs index acde4ca..19798ba 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,7 @@ use std::time::Instant; use anyhow::{Context, Error, Result}; use cfg_if::cfg_if; use clap::Parser; +use fdlimit::raise_fd_limit; use fs_err as fs; use humantime::Duration as HumanDuration; use tempfile::TempDir; @@ -37,6 +38,16 @@ fn main() -> Result<(), Error> { let shutdown_scan = shutdown.clone(); interrupt::setup_interrupt_handler(shutdown)?; + println!( + "Using {} threads for calibration and scanning", + args.threads + ); + + // Attempt to raise FD limit + if let Some(x) = raise_fd_limit() { + println!("Maximum number of file descriptors available: {x}"); + } + // Search only unique paths let mut visited_paths = HashSet::with_capacity(args.path.len()); diff --git a/src/walk.rs b/src/walk.rs index d472ca4..3e8d1ab 100644 --- a/src/walk.rs +++ b/src/walk.rs @@ -116,6 +116,11 @@ fn process_dir_entry( dir_count_walk: &Arc, ) { if let Ok(dir_entry) = dir_entry_result { + if let Some(ref err) = dir_entry.read_children_error { + println!("Fatal program error, exiting: {err}"); + process::exit(ERROR_EXIT) + } + if dir_entry.file_type.is_dir() { if let Some(full_path) = dir_entry.read_children_path.as_ref() { // Visited directory count