move max path size update to a later stage in the pipeline for accurate results

This commit is contained in:
sreedevk
2025-07-13 14:24:24 +00:00
parent 184efdcbbc
commit 47b2fc4a87
3 changed files with 9 additions and 6 deletions

View File

@@ -16,6 +16,7 @@ impl Interactive {
let mut itable = Table::new(); let mut itable = Table::new();
itable.set_format(*format::consts::FORMAT_NO_BORDER_LINE_SEPARATOR); itable.set_format(*format::consts::FORMAT_NO_BORDER_LINE_SEPARATOR);
itable.set_titles(row!["index", "filename", "size", "updated_at"]); itable.set_titles(row!["index", "filename", "size", "updated_at"]);
let max_path_size = group let max_path_size = group
.iter() .iter()
.map(|f| f.path.iter().count()) .map(|f| f.path.iter().count())

View File

@@ -20,6 +20,7 @@ impl Processor {
sw_store: Arc<DashMap<u64, Vec<FileInfo>>>, sw_store: Arc<DashMap<u64, Vec<FileInfo>>>,
hw_store: Arc<DashMap<String, Vec<FileInfo>>>, hw_store: Arc<DashMap<String, Vec<FileInfo>>>,
progress_bar_box: Arc<MultiProgress>, progress_bar_box: Arc<MultiProgress>,
max_file_size: Arc<AtomicU64>,
) -> Result<()> { ) -> Result<()> {
let progress_bar = match app_args.progress { let progress_bar = match app_args.progress {
true => progress_bar_box.add(ProgressBar::new_spinner()), true => progress_bar_box.add(ProgressBar::new_spinner()),
@@ -48,6 +49,12 @@ impl Processor {
file.initial_page_hash().expect("hashing file failed.") file.initial_page_hash().expect("hashing file failed.")
}; };
Self::compare_and_update_max_path_len(
max_file_size.clone(),
file.path.to_string_lossy().len() as u64,
)
.unwrap();
hw_store hw_store
.entry(fhash) .entry(fhash)
.and_modify(|fileset| fileset.push(file.clone())) .and_modify(|fileset| fileset.push(file.clone()))
@@ -72,7 +79,6 @@ impl Processor {
scanner_finished: Arc<AtomicBool>, scanner_finished: Arc<AtomicBool>,
store: Arc<DashMap<u64, Vec<FileInfo>>>, store: Arc<DashMap<u64, Vec<FileInfo>>>,
files: Arc<Mutex<Vec<FileInfo>>>, files: Arc<Mutex<Vec<FileInfo>>>,
max_file_size: Arc<AtomicU64>,
progress_bar_box: Arc<MultiProgress>, progress_bar_box: Arc<MultiProgress>,
) -> Result<()> { ) -> Result<()> {
let progress_bar = match app_args.progress { let progress_bar = match app_args.progress {
@@ -97,10 +103,6 @@ impl Processor {
match fileopt { match fileopt {
Some(file) => { Some(file) => {
progress_bar.inc(1); progress_bar.inc(1);
Self::compare_and_update_max_path_len(
max_file_size.clone(),
file.path.to_string_lossy().len() as u64,
)?;
store store
.entry(file.size) .entry(file.size)
.and_modify(|fileset| fileset.push(file.clone())) .and_modify(|fileset| fileset.push(file.clone()))

View File

@@ -72,7 +72,6 @@ impl Server {
sfin_pr_tr_cl, sfin_pr_tr_cl,
store_dupl_sw_for_sw, store_dupl_sw_for_sw,
file_queue_clone_pr, file_queue_clone_pr,
max_file_path_len_clone,
progbarbox_pr_clone.clone(), progbarbox_pr_clone.clone(),
) )
.unwrap(); .unwrap();
@@ -82,6 +81,7 @@ impl Server {
store_dupl_sw_for_hw, store_dupl_sw_for_hw,
store_dupl_hw, store_dupl_hw,
progbarbox_pr_clone, progbarbox_pr_clone,
max_file_path_len_clone,
) )
.unwrap(); .unwrap();
}); });