Skip to content

Commit

Permalink
use bon
Browse files Browse the repository at this point in the history
  • Loading branch information
jRimbault committed Aug 27, 2024
1 parent 67826eb commit f94a23c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 32 deletions.
17 changes: 0 additions & 17 deletions src/fs/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,10 @@ pub struct FileFilter {
max: Option<u64>,
regex: Option<regex::Regex>,
glob: Option<globset::GlobMatcher>,
#[cfg(unix)]
inodes_filter: inode::Filter,

Check failure on line 10 in src/fs/filter.rs

View workflow job for this annotation

GitHub Actions / Check build (windows-latest, 1.74.1, --no-default-features)

failed to resolve: use of undeclared crate or module `inode`

Check failure on line 10 in src/fs/filter.rs

View workflow job for this annotation

GitHub Actions / Check build (windows-latest, 1.74.1, --all-features)

failed to resolve: use of undeclared crate or module `inode`

Check failure on line 10 in src/fs/filter.rs

View workflow job for this annotation

GitHub Actions / Check build (windows-latest, stable, --no-default-features)

failed to resolve: use of undeclared crate or module `inode`

Check failure on line 10 in src/fs/filter.rs

View workflow job for this annotation

GitHub Actions / Check build (windows-latest, stable, --all-features)

failed to resolve: use of undeclared crate or module `inode`
}

impl FileFilter {
#[cfg(not(unix))]
pub fn new(
min: Option<u64>,
max: Option<u64>,
regex: Option<regex::Regex>,
glob: Option<globset::GlobMatcher>,
) -> Self {
Self {
min,
max,
regex,
glob,
}
}

#[cfg(unix)]
pub fn new(
min: Option<u64>,
max: Option<u64>,
Expand Down
21 changes: 6 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//!
//! ```toml
//! [dependencies]
//! yadf = { version = "0.15.0", default-features = false }
//! yadf = { version = "*", default-features = false }
//! ```
//!
//! A collection of functions and structs to find duplicate files.
Expand All @@ -14,7 +14,7 @@
//! Find and display all the duplicate files at the given paths :
//!
//! ```no_run
//! # fn foo(paths: &[std::path::PathBuf]) {
//! # fn foo(paths: Vec<std::path::PathBuf>) {
//! let counter = yadf::Yadf::builder()
//! .paths(paths)
//! .build()
Expand Down Expand Up @@ -45,13 +45,13 @@ pub type FileReplicates<'a> = bag::Replicates<'a, u64, Path>;
/// # Example
///
/// ```no_run
/// # fn foo(paths: &[std::path::PathBuf]) {
/// # fn foo(paths: Vec<std::path::PathBuf>) {
/// let counter = yadf::Yadf::builder()
/// .paths(paths) // required
/// .minimum_file_size(64) // optional
/// .maximum_file_size(1024 * 8) // optional
/// .regex(None) // optional
/// .glob(None) // optional
/// .maybe_regex(None) // optional
/// .maybe_glob(None) // optional
/// .build()
/// .scan::<seahash::SeaHasher>();
/// # }
Expand All @@ -73,8 +73,7 @@ pub struct Yadf {
regex: Option<regex::Regex>,
/// File name must match this glob
glob: Option<globset::Glob>,
#[cfg_attr(unix, doc = "Treat hard links as duplicates")]
#[cfg(unix)]
/// Treat hard links as duplicates
#[builder(default)]
hard_links: bool,
}
Expand All @@ -85,21 +84,13 @@ impl Yadf {
where
H: Hasher + Default,
{
#[cfg(unix)]
let file_filter = fs::filter::FileFilter::new(
self.minimum_file_size,
self.maximum_file_size,
self.regex,
self.glob.map(|g| g.compile_matcher()),
self.hard_links,
);
#[cfg(not(unix))]
let file_filter = fs::filter::FileFilter::new(
self.minimum_file_size,
self.maximum_file_size,
self.regex,
self.glob.map(|g| g.compile_matcher()),
);
let bag = fs::find_dupes_partial::<H, _>(&self.paths, self.max_depth, file_filter);
if log::log_enabled!(log::Level::Info) {
log::info!(
Expand Down

0 comments on commit f94a23c

Please sign in to comment.