mirror of https://github.com/perkeep/perkeep.git
pkg/client: Fix ignored files matching.
Because of Go's rules regaring closures (function literals) and bound variables, in the case in which there were multiple patterns in the ignoredFiles configuration variable, the entire slice (vector) of registered matching functions was being called with the last-configured ignoredFiles pattern as the first variable. This meant that ignoredFiles did not work if it contained more than one pattern and in certain circumstances, such a configuration would lead to a crash. Change-Id: I0b991aa74d079d4ce27fc0ba373e2ee2cf9eb772
This commit is contained in:
parent
e3491e5515
commit
d373f86d9f
|
@ -460,12 +460,14 @@ func newIgnoreChecker(ignoredFiles []string) func(path string) (shouldIgnore boo
|
|||
// 3) absolute paths
|
||||
// 4) paths components
|
||||
for _, pattern := range ignFiles {
|
||||
pattern := pattern
|
||||
_, err := filepath.Match(pattern, "whatever")
|
||||
if err == nil {
|
||||
fns = append(fns, func(v string) bool { return isShellPatternMatch(pattern, v) })
|
||||
}
|
||||
}
|
||||
for _, pattern := range ignFiles {
|
||||
pattern := pattern
|
||||
if filepath.IsAbs(pattern) {
|
||||
fns = append(fns, func(v string) bool { return hasDirPrefix(filepath.Clean(pattern), v) })
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue