Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ pub struct Opt {
#[structopt(short, long)]
/// Don't ask for confirmation before deleting
disable_delete_confirmation: bool,
#[structopt(short, long)]
/// The max depth of directories
max_depth: Option<usize>,
}

fn main() {
Expand Down Expand Up @@ -91,6 +94,7 @@ fn try_main() -> Result<(), failure::Error> {
folder,
opts.apparent_size,
opts.disable_delete_confirmation,
opts.max_depth,
);
}
Err(_) => failure::bail!("Failed to get stdout: are you trying to pipe 'diskonaut'?"),
Expand All @@ -105,6 +109,7 @@ pub fn start<B>(
path: PathBuf,
show_apparent_size: bool,
disable_delete_confirmation: bool,
max_depth: Option<usize>,
) where
B: Backend + Send + 'static,
{
Expand Down Expand Up @@ -187,16 +192,21 @@ pub fn start<B>(
let instruction_sender = instruction_sender.clone();
let loaded = loaded.clone();
move || {
'scanning: for entry in WalkDir::new(&path)
let walker = WalkDir::new(&path)
.parallelism(if SHOULD_SCAN_HD_FILES_IN_MULTIPLE_THREADS {
RayonDefaultPool
} else {
Serial
})
.skip_hidden(false)
.follow_links(false)
.into_iter()
{
.follow_links(false);

let walker_with_depth = match max_depth {
Some(depth) => walker.max_depth(depth),
None => walker,
};

'scanning: for entry in walker_with_depth.into_iter() {
let instruction_sent = match entry {
Ok(entry) => match entry.metadata() {
Ok(file_metadata) => {
Expand Down