polling, ignore young files

This commit is contained in:
Sebastian Frank 2021-08-16 20:30:00 +02:00
parent 5d52e3c35c
commit 50b1c7205d
Signed by: apairon
GPG Key ID: A0E05A8199CE3F57

18
main.go

@ -196,13 +196,17 @@ func startWatcher(directory *DirectoryConfig) {
for _, f := range files { for _, f := range files {
p := directory.Path + "/" + f.Name() p := directory.Path + "/" + f.Name()
if directory._regex == nil || directory._regex.MatchString(p) { if directory._regex == nil || directory._regex.MatchString(p) {
pollI := pollInfo{ if time.Now().Add(-1 * time.Minute).After(f.ModTime()) {
path: p, pollI := pollInfo{
event: 0, path: p,
} event: 0,
select { }
case c <- pollI: select {
default: case c <- pollI:
default:
}
} else {
log.Printf("[ INFO ] path=\"%s\" polling=\"true\" info=\"ignoring, too young\"\n", p)
} }
} else { } else {
log.Printf("[ INFO ] path=\"%s\" polling=\"true\" info=\"no regex match\"\n", p) log.Printf("[ INFO ] path=\"%s\" polling=\"true\" info=\"no regex match\"\n", p)