Skip to content

Commit

Permalink
Fix the infinite recursion by skipping the current directory in the d…
Browse files Browse the repository at this point in the history
…irectory names listing
  • Loading branch information
erstam committed Nov 14, 2023
1 parent ee6eef7 commit 04235e8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions path.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ func walk(fs Fs, path string, info os.FileInfo, walkFn filepath.WalkFunc) error
}

for _, name := range names {
if name == path {
// skip current directory to avoid infinite recursion
continue
}
filename := filepath.Join(path, name)
fileInfo, err := lstatIfPossible(fs, filename)
if err != nil {
Expand Down

0 comments on commit 04235e8

Please sign in to comment.