Fix CSV path joining and relative exclusions; add scan benchmark script
This commit is contained in:
@@ -138,6 +138,17 @@ type inodeKey struct{ dev, ino uint64 }
|
||||
// Start stats root, creates the tree and begins scanning in the background.
|
||||
func Start(ctx context.Context, root string, opts Options) (*Scanner, error) {
|
||||
opts.defaults()
|
||||
// Path-style exclusions are matched against absolute paths.
|
||||
excl := make([]string, len(opts.Excludes))
|
||||
for i, p := range opts.Excludes {
|
||||
excl[i] = p
|
||||
if strings.ContainsAny(p, `/\`) {
|
||||
if a, err := filepath.Abs(p); err == nil {
|
||||
excl[i] = a
|
||||
}
|
||||
}
|
||||
}
|
||||
opts.Excludes = excl
|
||||
abs, err := filepath.Abs(root)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -237,6 +237,12 @@ func TestExcludes(t *testing.T) {
|
||||
if tr.Stats.Excluded != 2 || tr.Node(0).Files != 1 {
|
||||
t.Fatalf("excluded=%d files=%d", tr.Stats.Excluded, tr.Node(0).Files)
|
||||
}
|
||||
// Relative path patterns resolve against the working directory.
|
||||
t.Chdir(root)
|
||||
tr = runScan(t, root, Options{Workers: 2, Excludes: []string{"./skip"}})
|
||||
if tr.Stats.Excluded != 1 {
|
||||
t.Fatalf("relative exclude: excluded=%d", tr.Stats.Excluded)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnicodeAndHostileNames(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user