lib/fs: Pass infinite recursion error on instead of warning (#6846)
Prompted by https://forum.syncthing.net/t/infinite-filesystem-recursion-detected/15285. In my opinion the filesystem shouldn't throw warnings but pass on errors for the caller to decide what's to be happening with it. Right now in this PR an infinite recursion is a normal scan error, i.e. folder is in failed state and displays failed items, but no warning. I think that's appropriate but if deemed appropriate an additional warning can be thrown in the scanner.
This commit is contained in:
+4
-2
@@ -11,9 +11,12 @@
|
||||
package fs
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
var ErrInfiniteRecursion = errors.New("infinite filesystem recursion detected")
|
||||
|
||||
type ancestorDirList struct {
|
||||
list []FileInfo
|
||||
fs Filesystem
|
||||
@@ -90,8 +93,7 @@ func (f *walkFilesystem) walk(path string, info FileInfo, walkFn WalkFunc, ances
|
||||
ancestors.Push(info)
|
||||
defer ancestors.Pop()
|
||||
} else {
|
||||
l.Warnf("Infinite filesystem recursion detected on path '%s', not walking further down", path)
|
||||
return nil
|
||||
return walkFn(path, info, ErrInfiniteRecursion)
|
||||
}
|
||||
|
||||
names, err := f.DirNames(path)
|
||||
|
||||
Reference in New Issue
Block a user