Skip to content

Commit

Permalink
Fixed checksum mode always being on
Browse files Browse the repository at this point in the history
  • Loading branch information
PsychedelicShayna committed Sep 14, 2024
1 parent b992193 commit ba65830
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use clap::parser::ValueSource;
use clap::{self, value_parser, Arg, ArgAction, Command};
use crossbeam_channel::unbounded;
use jwalk::WalkDir;
Expand Down Expand Up @@ -462,17 +463,24 @@ files you're traversing, the more it begins to add up.")
})
});


let checksum_mode = matches!(
matches.value_source("checksum"),
Some(ValueSource::CommandLine)
) || matches!(
matches.value_source("checksum-algo"),
Some(ValueSource::CommandLine)
);

let options = Options {
live_print: *matches.get_one::<bool>("live-print").unwrap_or(&false),
exclude: exclude_flags,
checksum: (matches.contains_id("checksum") || matches.contains_id("checksum-algo")).then(
|| {
matches
.get_one::<String>("checksum-algo")
.map(HashAlgorithm::from)
.unwrap_or(HashAlgorithm::Xxh3)
},
),
checksum: checksum_mode.then(|| {
matches
.get_one::<String>("checksum-algo")
.map(HashAlgorithm::from)
.unwrap_or(HashAlgorithm::Xxh3)
}),
checksum_threads: *matches.get_one("checksum-threads").unwrap_or(&1),
depth: *matches.get_one("depth").unwrap_or(&0),
directories: walk_dirs,
Expand Down

0 comments on commit ba65830

Please sign in to comment.