Properly match new files on windows when doing file acquisition (#2329)
This commit is contained in:
parent
01d7c1a5c2
commit
1295de928a
|
@ -7,7 +7,6 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -371,12 +370,13 @@ func (f *FileSource) monitorNewFiles(out chan types.Event, t *tomb.Tomb) error {
|
||||||
matched := false
|
matched := false
|
||||||
for _, pattern := range f.config.Filenames {
|
for _, pattern := range f.config.Filenames {
|
||||||
logger.Debugf("Matching %s with %s", pattern, event.Name)
|
logger.Debugf("Matching %s with %s", pattern, event.Name)
|
||||||
matched, err = path.Match(pattern, event.Name)
|
matched, err = filepath.Match(pattern, event.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("Could not match pattern : %s", err)
|
logger.Errorf("Could not match pattern : %s", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if matched {
|
if matched {
|
||||||
|
logger.Debugf("Matched %s with %s", pattern, event.Name)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,7 +260,7 @@ func TestLiveAcquisition(t *testing.T) {
|
||||||
// if we do not have access to the file
|
// if we do not have access to the file
|
||||||
permDeniedFile = `C:\Windows\System32\config\SAM`
|
permDeniedFile = `C:\Windows\System32\config\SAM`
|
||||||
permDeniedError = `unable to read C:\Windows\System32\config\SAM : open C:\Windows\System32\config\SAM: The process cannot access the file because it is being used by another process`
|
permDeniedError = `unable to read C:\Windows\System32\config\SAM : open C:\Windows\System32\config\SAM: The process cannot access the file because it is being used by another process`
|
||||||
testPattern = `test_files\\*.log` // the \ must be escaped for the yaml config
|
testPattern = `test_files\*.log`
|
||||||
}
|
}
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
|
|
Loading…
Reference in a new issue