Skip to content

Commit

Permalink
Ignore local dir walk errors if files were found (#1)
Browse files Browse the repository at this point in the history
If at least one file was found while walking a local directory, then
ignore any other errors so that some can run on these files.
  • Loading branch information
abhiseksanyal committed Nov 18, 2023
1 parent 49c0eed commit bc0efb9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions clients/localdir/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ func listFiles(clientPath string) ([]string, error) {

return nil
})
if err != nil {
return nil, fmt.Errorf("error walking the path %q: %w", clientPath, err)
if err != nil { // If any files were found, then return them, and let the caller choose to process it
return files, fmt.Errorf("error walking the path %q: %w", clientPath, err)
}

return files, nil
Expand All @@ -123,7 +123,8 @@ func applyPredicate(
errFiles error,
predicate func(string) (bool, error),
) ([]string, error) {
if errFiles != nil {
// If there was an error and no client files were found, then return here; else process client files at best effort
if errFiles != nil && len(clientFiles) == 0 {
return nil, errFiles
}

Expand Down

0 comments on commit bc0efb9

Please sign in to comment.