Skip to content

Commit

Permalink
Merge pull request #55 from moorereason/iss54
Browse files Browse the repository at this point in the history
Ignore eml files when processing extracted reports
  • Loading branch information
tierpod authored Apr 15, 2024
2 parents 96ba341 + 287e737 commit 8fb9dd0
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion cmd/dmarc-report-converter/files.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"io/fs"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -85,7 +86,24 @@ func (c *filesConverter) find() error {
}
}

files, err := filepath.Glob(filepath.Join(c.cfg.Input.Dir, "*.*"))
// Walk Input.Dir for a list of files to process, skipping eml files.
var files []string
err = filepath.Walk(c.cfg.Input.Dir, func(path string, info fs.FileInfo, err error) error {
if err != nil {
return err
}

if info.IsDir() {
// Process the root dir but don't recurse
if path != c.cfg.Input.Dir {
return filepath.SkipDir
}
} else if filepath.Ext(path) != ".eml" {
files = append(files, path)
}

return nil
})
if err != nil {
return err
}
Expand Down

0 comments on commit 8fb9dd0

Please sign in to comment.