Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6cf55a6

Browse files
committed
Added symlinks loop-filtering subroutine
1 parent 973dee8 commit 6cf55a6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎internal/arduino/sketch/sketch.go‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,26 @@ func (s *Sketch) supportedFiles() (paths.PathList, error) {
174174
return err == nil
175175
}
176176

177+
var loopErr error
178+
explored := map[string]bool{}
179+
filterLoops := func(p *paths.Path) bool {
180+
dir := p.Canonical().String()
181+
if explored[dir] {
182+
loopErr = errors.New("directories symlink loop detected")
183+
return false
184+
}
185+
explored[dir] = true
186+
return true
187+
}
188+
177189
files, err := s.FullPath.ReadDirRecursiveFiltered(
178190
paths.AndFilter(
179191
paths.OrFilter(
180192
filterValidExtensions,
181193
filterOutBrokenLinks,
182194
),
183195
filterOutBuildPaths,
196+
filterLoops,
184197
),
185198
paths.AndFilter(
186199
paths.FilterOutPrefixes("."),
@@ -191,6 +204,9 @@ func (s *Sketch) supportedFiles() (paths.PathList, error) {
191204
if err != nil {
192205
return nil, err
193206
}
207+
if loopErr != nil {
208+
return nil, loopErr
209+
}
194210
return files, nil
195211
}
196212

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /