mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-16 08:27:06 +08:00
vendor: update buildkit with typed errors support
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
27
vendor/github.com/tonistiigi/fsutil/walker.go
generated
vendored
27
vendor/github.com/tonistiigi/fsutil/walker.go
generated
vendored
@ -25,21 +25,21 @@ type WalkOpt struct {
|
||||
func Walk(ctx context.Context, p string, opt *WalkOpt, fn filepath.WalkFunc) error {
|
||||
root, err := filepath.EvalSymlinks(p)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to resolve %s", root)
|
||||
return errors.WithStack(&os.PathError{Op: "resolve", Path: root, Err: err})
|
||||
}
|
||||
fi, err := os.Stat(root)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to stat: %s", root)
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
if !fi.IsDir() {
|
||||
return errors.Errorf("%s is not a directory", root)
|
||||
return errors.WithStack(&os.PathError{Op: "walk", Path: root, Err: syscall.ENOTDIR})
|
||||
}
|
||||
|
||||
var pm *fileutils.PatternMatcher
|
||||
if opt != nil && opt.ExcludePatterns != nil {
|
||||
pm, err = fileutils.NewPatternMatcher(opt.ExcludePatterns)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "invalid excludepaths %s", opt.ExcludePatterns)
|
||||
return errors.Wrapf(err, "invalid excludepatterns: %s", opt.ExcludePatterns)
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,17 +65,15 @@ func Walk(ctx context.Context, p string, opt *WalkOpt, fn filepath.WalkFunc) err
|
||||
|
||||
seenFiles := make(map[uint64]string)
|
||||
return filepath.Walk(root, func(path string, fi os.FileInfo, err error) (retErr error) {
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if retErr != nil && isNotExist(retErr) {
|
||||
retErr = filepath.SkipDir
|
||||
}
|
||||
}()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
origpath := path
|
||||
path, err = filepath.Rel(root, path)
|
||||
if err != nil {
|
||||
@ -219,12 +217,5 @@ func trimUntilIndex(str, sep string, count int) string {
|
||||
}
|
||||
|
||||
func isNotExist(err error) bool {
|
||||
err = errors.Cause(err)
|
||||
if os.IsNotExist(err) {
|
||||
return true
|
||||
}
|
||||
if pe, ok := err.(*os.PathError); ok {
|
||||
err = pe.Err
|
||||
}
|
||||
return err == syscall.ENOTDIR
|
||||
return errors.Is(err, os.ErrNotExist) || errors.Is(err, syscall.ENOTDIR)
|
||||
}
|
||||
|
Reference in New Issue
Block a user