Skip to content

Commit

Permalink
Update deps. Add fd limit raise. Handle fatal dir scan I/O errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkorunic committed Nov 3, 2023
1 parent e3ac5cf commit 94f5ef8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "findlargedir"
version = "0.5.7"
version = "0.6.0"
authors = ["Dinko Korunic <[email protected]>"]
categories = ["command-line-utilities"]
description = "find all blackhole directories with a huge amount of filesystem entries in a flat structure"
Expand All @@ -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 }
Expand Down
11 changes: 11 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());

Expand Down
5 changes: 5 additions & 0 deletions src/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ fn process_dir_entry<E>(
dir_count_walk: &Arc<AtomicU64>,
) {
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
Expand Down

0 comments on commit 94f5ef8

Please sign in to comment.