diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a184c17..c1336ff 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,12 +16,3 @@ repos: rev: v1.23.6 hooks: - id: typos - - - repo: local - hooks: - - id: cargo-fmt - name: cargo fmt - entry: cargo fmt -- - language: system - types: [rust] - pass_filenames: false # This makes it a lot faster diff --git a/src/results.rs b/src/results.rs index 7564405..e022762 100644 --- a/src/results.rs +++ b/src/results.rs @@ -25,18 +25,30 @@ impl AnalysisResults { println!("{}", format!("Elapsed time: {} ms", elapsed_ms).blue()); // Format file_count and dir_count with a thousand separators - let file_count_formatted = self + let n_files_identified_formatted = self .complete_statistics - .n_files_analyzed + .n_files_identified .to_formatted_string(&Locale::en); let dir_count_formatted = self .complete_statistics .n_directories_visited .to_formatted_string(&Locale::en); + let n_files_considered_formatted = self + .complete_statistics + .n_files_considered + .to_formatted_string(&Locale::en); + let n_files_hashed_formatted = self + .complete_statistics + .n_files_hashed + .to_formatted_string(&Locale::en); println!( "{}", - format!("Number of files analyzed: {}", file_count_formatted).green() + format!( + "Number of files identified: {}", + n_files_identified_formatted + ) + .green() ); println!( "{}", @@ -50,6 +62,18 @@ impl AnalysisResults { ) .green() ); + println!( + "{}", + format!( + "Number of files considered: {}", + n_files_considered_formatted + ) + .green() + ); + println!( + "{}", + format!("Number of files hashed: {}", n_files_hashed_formatted).green() + ); println!(); println!("{}", "Largest files:".bold().underline().yellow()); diff --git a/src/traversal.rs b/src/traversal.rs index 5a17035..45ebccb 100644 --- a/src/traversal.rs +++ b/src/traversal.rs @@ -9,7 +9,9 @@ pub struct DirectoryTraversalOutput { } pub struct CompleteTraversalStatistics { - pub n_files_analyzed: usize, + pub n_files_identified: usize, + pub n_files_considered: usize, + pub n_files_hashed: usize, pub n_directories_visited: usize, pub max_depth_visited: usize, } @@ -21,13 +23,11 @@ pub fn traverse_directory( ) -> DirectoryTraversalOutput { let mut n_directories_visited = 1; let mut max_depth_visited = 0; - let mut n_files_analyzed = 0; + let mut n_files_identified = 0; + let mut n_files_considered = 0; + let mut n_files_hashed = 0; let file_infos: Vec = WalkBuilder::new(dir) - .hidden(true) - .ignore(true) - .git_ignore(true) - .git_global(true) - .git_exclude(true) + .standard_filters(true) .build() .filter_map(|e| e.ok()) .filter_map(|entry| { @@ -39,15 +39,20 @@ pub fn traverse_directory( n_directories_visited += 1; } if entry.file_type().map_or(false, |ft| ft.is_file()) { - n_files_analyzed += 1; + n_files_identified += 1; let path = entry.into_path(); if !file_extensions.is_empty() && !file_utils::has_allowed_extension(&path, file_extensions) { return None; } + n_files_considered += 1; let size = get_file_size(&path); - let hash = if size > *min_file_size as u64 { + let should_calculate_hash = size > *min_file_size as u64; + if should_calculate_hash { + n_files_hashed += 1; + } + let hash = if should_calculate_hash { calculate_hash(&path).unwrap_or_else(|_| String::new()) } else { String::new() @@ -60,7 +65,9 @@ pub fn traverse_directory( .collect(); let complete_statistics = CompleteTraversalStatistics { - n_files_analyzed, + n_files_identified, + n_files_considered, + n_files_hashed, n_directories_visited, max_depth_visited, };