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
View File

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