Skip to content

Commit

Permalink
maybe should check the result of filepath.Glob() and return an error (#…
Browse files Browse the repository at this point in the history
…265)

* fix: return error while check file doesn't exist
---------

Co-authored-by: Vee Zhang <[email protected]>
  • Loading branch information
LooJee and veezhang authored May 17, 2023
1 parent 4cd85fb commit 4eeb7d0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,7 @@ func (config *YAMLConfig) expandDirectoryToFiles(dir string) (err error) {
logger.Log.Errorf("error when expand file: %s", err)
return err
}
for _, f := range files {
newFiles = append(newFiles, f)
}
newFiles = append(newFiles, files...)
}
config.Files = newFiles

Expand Down Expand Up @@ -408,11 +406,15 @@ func (f *File) expandFiles(dir string) ([]*File, error) {
}

fileNames, err := filepath.Glob(*f.Path)
if err != nil || len(fileNames) == 0 {
if err != nil {
logger.Log.Errorf("error file path: %s", *f.Path)
return files, err
}

if len(fileNames) == 0 {
return files, &os.PathError{Op: "open", Path: *f.Path, Err: os.ErrNotExist}
}

for i := range fileNames {
var failedDataPath *string = nil
if f.FailDataPath != nil {
Expand Down

0 comments on commit 4eeb7d0

Please sign in to comment.