From 50b1c7205d2c2429737b3e294c1d6dcfdd137290 Mon Sep 17 00:00:00 2001 From: Sebastian Frank <sebastian@webmakers.de> Date: Mon, 16 Aug 2021 20:30:00 +0200 Subject: [PATCH] polling, ignore young files --- main.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 0edce2b..0d48037 100644 --- a/main.go +++ b/main.go @@ -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)