@@ -21,27 +21,33 @@ struct Executor {
2121}
2222
2323impl Executor {
24+ fn is_excluded ( & self , path : & str ) -> bool {
25+ self . excluded_glob_set
26+ . as_ref ( )
27+ . map_or ( false , |glob_set| glob_set. is_match ( path) )
28+ }
29+
30+ fn is_file_included ( & self , path : & str ) -> bool {
31+ self . included_glob_set
32+ . as_ref ( )
33+ . map_or ( true , |glob_set| glob_set. is_match ( path) )
34+ && !self . is_excluded ( path)
35+ }
36+
2437 async fn traverse_dir ( & self , dir_path : & PathBuf , result : & mut Vec < KeyValue > ) -> Result < ( ) > {
2538 for entry in std:: fs:: read_dir ( dir_path) ? {
2639 let entry = entry?;
2740 let path = entry. path ( ) ;
2841 if let Some ( file_name) = path. to_str ( ) {
2942 let relative_path = & file_name[ self . root_path_str . len ( ) + 1 ..] ;
30- if self
31- . excluded_glob_set
32- . as_ref ( )
33- . map_or ( false , |glob_set| glob_set. is_match ( relative_path) )
34- {
35- continue ;
36- }
3743 if path. is_dir ( ) {
38- Box :: pin ( self . traverse_dir ( & path , result ) ) . await ? ;
39- } else if self
40- . included_glob_set
41- . as_ref ( )
42- . map_or ( true , |glob_set| glob_set . is_match ( relative_path) )
43- {
44- result . push ( KeyValue :: Str ( Arc :: from ( relative_path ) ) ) ;
44+ if ! self . is_excluded ( relative_path ) {
45+ Box :: pin ( self . traverse_dir ( & path , result ) ) . await ? ;
46+ }
47+ } else {
48+ if self . is_file_included ( relative_path) {
49+ result . push ( KeyValue :: Str ( Arc :: from ( relative_path ) ) ) ;
50+ }
4551 }
4652 } else {
4753 warn ! ( "Skipped ill-formed file path: {}" , path. display( ) ) ;
@@ -60,6 +66,9 @@ impl SourceExecutor for Executor {
6066 }
6167
6268 async fn get_value ( & self , key : & KeyValue ) -> Result < Option < FieldValues > > {
69+ if !self . is_file_included ( key. str_value ( ) ?. as_ref ( ) ) {
70+ return Ok ( None ) ;
71+ }
6372 let path = self . root_path . join ( key. str_value ( ) ?. as_ref ( ) ) ;
6473 let result = match std:: fs:: read ( path) {
6574 Ok ( content) => {
0 commit comments