File tree 2 files changed +17
-1
lines changed
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -333,7 +333,9 @@ func (p *Path) ReadDirRecursive() (PathList, error) {
333
333
path := p .Clone ().Join (info .Name ())
334
334
paths .Add (path )
335
335
336
- if path .IsDir () {
336
+ if isDir , err := path .IsDirCheck (); err != nil {
337
+ return nil , err
338
+ } else if isDir {
337
339
subPaths , err := path .ReadDirRecursive ()
338
340
if err != nil {
339
341
return nil , err
Original file line number Diff line number Diff line change 30
30
package paths
31
31
32
32
import (
33
+ "os"
33
34
"path/filepath"
34
35
"runtime"
35
36
"strings"
@@ -277,6 +278,19 @@ func TestReadDirRecursive(t *testing.T) {
277
278
pathEqualsTo (t , "_testdata/symlinktofolder/subfolder/file4" , list [13 ])
278
279
pathEqualsTo (t , "_testdata/test.txt" , list [14 ])
279
280
pathEqualsTo (t , "_testdata/test.txt.gz" , list [15 ])
281
+
282
+ // Test symlink loop
283
+ tmp , err := MkTempDir ("" , "" )
284
+ require .NoError (t , err )
285
+ defer tmp .RemoveAll ()
286
+
287
+ folder := tmp .Join ("folder" )
288
+ err = os .Symlink (tmp .String (), folder .String ())
289
+ require .NoError (t , err )
290
+
291
+ l , err := tmp .ReadDirRecursive ()
292
+ require .Error (t , err )
293
+ require .Nil (t , l )
280
294
}
281
295
282
296
func TestFilterDirs (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments