Skip to content

Commit

Permalink
improving
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaela-soares committed Jun 1, 2022
1 parent 22a3681 commit 56e6e72
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/engine/provider/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ func (s *FileSystemSourceProvider) checkConditions(info os.FileInfo, extensions
log.Trace().Msgf("File ignored: %s", path)
return true, nil
}
if !extensions.Include(filepath.Ext(path)) && !extensions.Include(filepath.Base(path)) {
ext := utils.GetExtension(path)
if !extensions.Include(ext) {
log.Trace().Msgf("File ignored: %s", path)
return true, nil
}
return false, nil
Expand Down
10 changes: 10 additions & 0 deletions pkg/utils/get_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ func GetExtension(path string) string {
}

func isTextFile(path string) bool {
info, err := os.Stat(path)
if err != nil {
log.Error().Msgf("failed to get file info: %s", err)
return false
}

if info.IsDir() {
return false
}

content, err := os.ReadFile(filepath.Clean(path))
if err != nil {
log.Error().Msgf("failed to analyze file: %s", err)
Expand Down

0 comments on commit 56e6e72

Please sign in to comment.