@@ -336,7 +336,7 @@ func (m *filesystemMerging) WithEachMerged(ctx context.Context, f func(context.C
336336 )
337337
338338 // Build a mapping of BatchHeader + EntryDetail from dir
339- mappings , err := m .buildDirMapping (dir )
339+ mappings , err := m .buildDirMapping (dir , canceledFiles )
340340 if err != nil {
341341 el .Add (err )
342342 }
@@ -395,9 +395,11 @@ func fileAcceptor(canceledFiles []string) func(string) ach.FileAcceptance {
395395 }
396396}
397397
398- func (m * filesystemMerging ) buildDirMapping (dir string ) (* treemap.TreeMap [string , string ], error ) {
398+ func (m * filesystemMerging ) buildDirMapping (dir string , canceledFiles [] string ) (* treemap.TreeMap [string , string ], error ) {
399399 tree := treemap .New [string , string ]()
400400
401+ acceptor := fileAcceptor (canceledFiles )
402+
401403 err := fs .WalkDir (m .storage , dir , func (path string , d fs.DirEntry , err error ) error {
402404 if err != nil {
403405 if strings .Contains (err .Error (), "is a directory" ) {
@@ -415,6 +417,11 @@ func (m *filesystemMerging) buildDirMapping(dir string) (*treemap.TreeMap[string
415417 return nil
416418 }
417419
420+ // Skip the file if merging would have skipped it
421+ if acceptor (path ) == ach .SkipFile {
422+ return nil
423+ }
424+
418425 fd , err := m .storage .Open (path )
419426 if err != nil {
420427 return fmt .Errorf ("opening %s failed: %w" , path , err )
0 commit comments