Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lint issues in lib/fsext #3482

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/fsext/changepathfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (f *ChangePathFile) Name() string {
}

// Chown changes the uid and gid of the named file.
func (b *ChangePathFs) Chown(name string, uid, gid int) error {
func (b *ChangePathFs) Chown(_ string, _, _ int) error {
return errors.New("unimplemented Chown")
mstoykov marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down
18 changes: 10 additions & 8 deletions lib/fsext/walk.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fsext

import (
"errors"
"io/fs"
"path/filepath"
"sort"
Expand Down Expand Up @@ -49,7 +50,7 @@ func readDirNames(fs afero.Fs, dirname string) ([]string, error) {
func walk(fileSystem afero.Fs, path string, info fs.FileInfo, walkFn filepath.WalkFunc) error {
err := walkFn(path, info, nil)
if err != nil {
if info.IsDir() && err == filepath.SkipDir {
if info.IsDir() && errors.Is(err, filepath.SkipDir) {
return nil
}
return err
Expand All @@ -68,15 +69,16 @@ func walk(fileSystem afero.Fs, path string, info fs.FileInfo, walkFn filepath.Wa
filename := JoinFilePath(path, name)
fileInfo, err := fileSystem.Stat(filename)
if err != nil {
if err = walkFn(filename, fileInfo, err); err != nil && err != filepath.SkipDir {
if err = walkFn(filename, fileInfo, err); err != nil && !errors.Is(err, filepath.SkipDir) {
return err
}
} else {
err = walk(fileSystem, filename, fileInfo, walkFn)
if err != nil {
if !fileInfo.IsDir() || err != filepath.SkipDir {
return err
}
return nil
}

err = walk(fileSystem, filename, fileInfo, walkFn)
if err != nil {
if !fileInfo.IsDir() || !errors.Is(err, filepath.SkipDir) {
return err
}
}
}
Expand Down