@@ -251,6 +251,7 @@ where
251251 & mut file_results,
252252 & extensions,
253253 & excluded_items,
254+ & directories,
254255 minimal_file_size,
255256 maximal_file_size,
256257 ) ;
@@ -389,6 +390,10 @@ fn process_file_in_file_mode(
389390 return ;
390391 }
391392
393+ if directories. is_excluded_file ( & current_file_name) {
394+ return ;
395+ }
396+
392397 #[ cfg( target_family = "unix" ) ]
393398 if directories. exclude_other_filesystems ( ) {
394399 match directories. is_on_other_filesystems ( & current_file_name) {
@@ -425,6 +430,7 @@ fn process_file_in_file_mode_path_check(
425430 fe_result : & mut Vec < FileEntry > ,
426431 extensions : & Extensions ,
427432 excluded_items : & ExcludedItems ,
433+ directories : & Directories ,
428434 minimal_file_size : u64 ,
429435 maximal_file_size : u64 ,
430436) {
@@ -435,6 +441,13 @@ fn process_file_in_file_mode_path_check(
435441 return ;
436442 }
437443
444+ if directories. is_excluded_file ( path) {
445+ return ;
446+ }
447+ if directories. is_excluded_item_in_dir ( path) {
448+ return ;
449+ }
450+
438451 if excluded_items. is_excluded ( path) {
439452 return ;
440453 }
@@ -464,7 +477,7 @@ fn process_dir_in_file_symlink_mode(
464477 }
465478
466479 let dir_path = entry_data. path ( ) ;
467- if directories. is_excluded ( & dir_path) {
480+ if directories. is_excluded_dir ( & dir_path) {
468481 return ;
469482 }
470483
@@ -752,7 +765,7 @@ mod tests {
752765 Ok ( ( ) )
753766 }
754767
755- fn create_temp_structure ( dir : & TempDir ) -> io:: Result < ( PathBuf , PathBuf ) > {
768+ fn create_temp_structure ( dir : & TempDir ) -> io:: Result < ( PathBuf , PathBuf , PathBuf ) > {
756769 let global = dir. path ( ) . join ( "global.txt" ) ;
757770 let other_dir = dir. path ( ) . join ( "other" ) ;
758771 fs:: create_dir_all ( & other_dir) ?;
@@ -766,13 +779,13 @@ mod tests {
766779 f2. write_all ( b"other" ) ?;
767780 f2. set_modified ( * NOW ) ?;
768781
769- Ok ( ( global, other) )
782+ Ok ( ( global, other, other_dir ) )
770783 }
771784
772785 #[ test]
773786 fn test_traversal_with_and_without_excluded_dir ( ) -> io:: Result < ( ) > {
774787 let dir = tempfile:: Builder :: new ( ) . tempdir ( ) ?;
775- let ( global, other) = create_temp_structure ( & dir) ?;
788+ let ( global, other, other_dir ) = create_temp_structure ( & dir) ?;
776789 let secs = NOW . duration_since ( SystemTime :: UNIX_EPOCH ) . expect ( "Cannot fail calculating duration since epoch" ) . as_secs ( ) ;
777790
778791 let mut common_data = CommonToolData :: new ( ToolType :: SimilarImages ) ;
@@ -797,7 +810,7 @@ mod tests {
797810
798811 let mut common_data2 = CommonToolData :: new ( ToolType :: SimilarImages ) ;
799812 common_data2. directories . set_included_paths ( [ dir. path ( ) . to_owned ( ) ] . to_vec ( ) ) ;
800- common_data2. directories . set_excluded_paths ( [ other . clone ( ) ] . to_vec ( ) ) ;
813+ common_data2. directories . set_excluded_paths ( [ other_dir . clone ( ) ] . to_vec ( ) ) ;
801814 common_data2. set_minimal_file_size ( 0 ) ;
802815
803816 match DirTraversalBuilder :: new ( )
@@ -817,7 +830,7 @@ mod tests {
817830
818831 let mut common_data2 = CommonToolData :: new ( ToolType :: SimilarImages ) ;
819832 common_data2. directories . set_included_paths ( [ dir. path ( ) . to_owned ( ) ] . to_vec ( ) ) ;
820- common_data2. directories . set_excluded_paths ( [ other. clone ( ) . join ( "other.txt" ) ] . to_vec ( ) ) ;
833+ common_data2. directories . set_excluded_paths ( [ other. clone ( ) ] . to_vec ( ) ) ;
821834 common_data2. set_minimal_file_size ( 0 ) ;
822835
823836 match DirTraversalBuilder :: new ( )
0 commit comments