feat: switch to globwalk

This commit is contained in:
beeb
2023-01-23 21:53:44 +01:00
parent 876fdc69ac
commit 6f8b1d55df
5 changed files with 122 additions and 13 deletions

View File

@@ -26,7 +26,7 @@ fn format_path(path: &str, opts: &Params) -> Result<String> {
display_path
};
Ok(format!("...{:<32}", display_range))
Ok(format!("...{display_range:<32}"))
}
fn file_size(file: &File) -> Result<String> {

View File

@@ -52,7 +52,7 @@ impl Params {
Some(filetypes) => vec![
self.get_directory().unwrap(),
String::from("**"),
format!("{{{}}}", filetypes),
format!("*.{{{filetypes}}}"),
]
.iter()
.collect::<PathBuf>(),

View File

@@ -2,7 +2,6 @@ use crate::{file_manager::File, filters, params::Params};
use anyhow::Result;
use dashmap::DashMap;
use fxhash::hash64 as hasher;
use glob::glob;
use indicatif::{ParallelProgressIterator, ProgressStyle};
use memmap2::Mmap;
use rayon::prelude::*;
@@ -41,10 +40,10 @@ pub fn duplicates(app_opts: &Params) -> Result<DashMap<String, Vec<File>>> {
fn scan(app_opts: &Params) -> Result<Vec<File>> {
let glob_patterns = app_opts.get_glob_patterns().display().to_string();
let glob_iter = glob(&glob_patterns)?;
let glob_iter = globwalk::glob(glob_patterns)?;
let files = glob_iter
.filter(Result::is_ok)
.map(|file| file.unwrap())
.filter_map(Result::ok)
.map(|file| file.into_path())
.filter(|fpath| fpath.is_file())
.collect::<Vec<PathBuf>>()
.into_par_iter()