parent
e7e39df6a0
commit
52134555d6
|
@ -36,6 +36,7 @@
|
||||||
- [#1768](https://github.com/influxdata/telegraf/pull/1768): Speed up statsd parsing.
|
- [#1768](https://github.com/influxdata/telegraf/pull/1768): Speed up statsd parsing.
|
||||||
- [#1751](https://github.com/influxdata/telegraf/issues/1751): Fix powerdns integer parse error handling.
|
- [#1751](https://github.com/influxdata/telegraf/issues/1751): Fix powerdns integer parse error handling.
|
||||||
- [#1752](https://github.com/influxdata/telegraf/issues/1752): Fix varnish plugin defaults not being used.
|
- [#1752](https://github.com/influxdata/telegraf/issues/1752): Fix varnish plugin defaults not being used.
|
||||||
|
- [#1517](https://github.com/influxdata/telegraf/issues/1517): Fix windows glob paths.
|
||||||
|
|
||||||
## v1.0.1 [unreleased]
|
## v1.0.1 [unreleased]
|
||||||
|
|
||||||
|
|
|
@ -12,21 +12,23 @@ import (
|
||||||
var sepStr = fmt.Sprintf("%v", string(os.PathSeparator))
|
var sepStr = fmt.Sprintf("%v", string(os.PathSeparator))
|
||||||
|
|
||||||
type GlobPath struct {
|
type GlobPath struct {
|
||||||
path string
|
path string
|
||||||
hasMeta bool
|
hasMeta bool
|
||||||
g glob.Glob
|
hasSuperMeta bool
|
||||||
root string
|
g glob.Glob
|
||||||
|
root string
|
||||||
}
|
}
|
||||||
|
|
||||||
func Compile(path string) (*GlobPath, error) {
|
func Compile(path string) (*GlobPath, error) {
|
||||||
out := GlobPath{
|
out := GlobPath{
|
||||||
hasMeta: hasMeta(path),
|
hasMeta: hasMeta(path),
|
||||||
path: path,
|
hasSuperMeta: hasSuperMeta(path),
|
||||||
|
path: path,
|
||||||
}
|
}
|
||||||
|
|
||||||
// if there are no glob meta characters in the path, don't bother compiling
|
// if there are no glob meta characters in the path, don't bother compiling
|
||||||
// a glob object or finding the root directory. (see short-circuit in Match)
|
// a glob object or finding the root directory. (see short-circuit in Match)
|
||||||
if !out.hasMeta {
|
if !out.hasMeta || !out.hasSuperMeta {
|
||||||
return &out, nil
|
return &out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +50,17 @@ func (g *GlobPath) Match() map[string]os.FileInfo {
|
||||||
}
|
}
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
if !g.hasSuperMeta {
|
||||||
|
out := make(map[string]os.FileInfo)
|
||||||
|
files, _ := filepath.Glob(g.path)
|
||||||
|
for _, file := range files {
|
||||||
|
info, err := os.Stat(file)
|
||||||
|
if !os.IsNotExist(err) {
|
||||||
|
out[file] = info
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
return walkFilePath(g.root, g.g)
|
return walkFilePath(g.root, g.g)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,3 +109,8 @@ func findRootDir(path string) string {
|
||||||
func hasMeta(path string) bool {
|
func hasMeta(path string) bool {
|
||||||
return strings.IndexAny(path, "*?[") >= 0
|
return strings.IndexAny(path, "*?[") >= 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// hasSuperMeta reports whether path contains any super magic glob characters (**).
|
||||||
|
func hasSuperMeta(path string) bool {
|
||||||
|
return strings.Index(path, "**") >= 0
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue