Skip to content

Commit

Permalink
Simplify logic
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelvigee committed Dec 15, 2023
1 parent 7029021 commit 36b3120
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions utils/xfs/walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ package xfs

import (
"context"
"errors"
"fmt"
"github.com/bmatcuk/doublestar/v4"
"github.com/hephbuild/heph/utils/ads"
"io/fs"
"os"
"path/filepath"
"strings"
)
Expand Down Expand Up @@ -123,25 +121,11 @@ func starWalk(ctx context.Context, root, pattern string, ignore []string, fn fs.

i := indexMeta(pattern)
if i == -1 {
// Pattern is actually a pure path

path := unescapeMeta(pattern)
info, err := os.Lstat(path)
if err != nil {
if errors.Is(err, fs.ErrNotExist) {
return nil
}

return err
}

if !info.IsDir() {
// It's not a directory, no need to walk
walkRoot = path
alwaysMatch = true
}

// All files recursively in the dir would match
// Pattern is actually a pure path
// If dir: all files recursively would match
// If file: it will call fn once with the file
alwaysMatch = true
walkRoot = path
} else if i > 0 {
Expand Down

0 comments on commit 36b3120

Please sign in to comment.