Skip to content

Commit

Permalink
Fixed infinite loops in tracking.
Browse files Browse the repository at this point in the history
  • Loading branch information
janpfeifer committed Jul 3, 2024
1 parent ec07209 commit a92bb7d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,16 @@ func SortedKeys[K constraints.Ordered, V any](m map[K]V) []K {
}

// WalkDirWithSymbolicLinks is similar filepath.WalkDir, but it follows symbolic links. It also checks for
// infinite loops in symbolic links, and returns an error if it finds one.
// infinite loops in symbolic links, and ignore them.
func WalkDirWithSymbolicLinks(root string, dirFunc fs.WalkDirFunc) error {
visited := MakeSet[string]()
return walkDirWithSymbolicLinksImpl(root, root, dirFunc, visited)
}

func walkDirWithSymbolicLinksImpl(root, current string, dirFunc fs.WalkDirFunc, visited Set[string]) error {
// Break infinite loops
// Break infinite loops, or simply repeated files/directories linked from different parts.
if visited.Has(current) {
return errors.Errorf("directory %q is in an infinite loop of symbolic links, cannot WalkDirWithSymbolicLinks(%q)", current, root)
return nil
}
visited.Insert(current)

Expand Down
3 changes: 3 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# GoNB Changelog

## Next
* Fixed tracking to simply ignore loops, but not interrupt traversal during tracking.

## 0.10.1, 2024/04/14 Added support for Apache ECharts

* Interrupt and Shutdown:
Expand Down

0 comments on commit a92bb7d

Please sign in to comment.