updating github.com/spf13/afero to v1.2.2

This commit is contained in:
Davanum Srinivas
2019-06-14 11:32:53 -04:00
parent caba257fc9
commit 56612c8b2e
55 changed files with 504 additions and 4585 deletions

View File

@@ -60,7 +60,7 @@ func walk(fs Fs, path string, info os.FileInfo, walkFn filepath.WalkFunc) error
for _, name := range names {
filename := filepath.Join(path, name)
fileInfo, err := lstatIfOs(fs, filename)
fileInfo, err := lstatIfPossible(fs, filename)
if err != nil {
if err := walkFn(filename, fileInfo, err); err != nil && err != filepath.SkipDir {
return err
@@ -77,15 +77,13 @@ func walk(fs Fs, path string, info os.FileInfo, walkFn filepath.WalkFunc) error
return nil
}
// if the filesystem is OsFs use Lstat, else use fs.Stat
func lstatIfOs(fs Fs, path string) (info os.FileInfo, err error) {
_, ok := fs.(*OsFs)
if ok {
info, err = os.Lstat(path)
} else {
info, err = fs.Stat(path)
// if the filesystem supports it, use Lstat, else use fs.Stat
func lstatIfPossible(fs Fs, path string) (os.FileInfo, error) {
if lfs, ok := fs.(Lstater); ok {
fi, _, err := lfs.LstatIfPossible(path)
return fi, err
}
return
return fs.Stat(path)
}
// Walk walks the file tree rooted at root, calling walkFn for each file or
@@ -100,7 +98,7 @@ func (a Afero) Walk(root string, walkFn filepath.WalkFunc) error {
}
func Walk(fs Fs, root string, walkFn filepath.WalkFunc) error {
info, err := lstatIfOs(fs, root)
info, err := lstatIfPossible(fs, root)
if err != nil {
return walkFn(root, nil, err)
}