From 3b67759495c9268c30e6ba2d8c7e3b75d52d2960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 12 Apr 2017 10:07:08 +0200 Subject: [PATCH] hugolib: Avoid processing the same notify event twice On `macOS`, at least, we've seen multiple WRITE events for same file, and no need to do the same job twice. --- hugolib/site.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hugolib/site.go b/hugolib/site.go index 768fe147f..d8e40f039 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -633,8 +633,15 @@ func (s *Site) reProcess(events []fsnotify.Event) (whatChanged, error) { shortcodesChanged := make(map[string]bool) // prevent spamming the log on changes logger := helpers.NewDistinctFeedbackLogger() + seen := make(map[fsnotify.Event]bool) for _, ev := range events { + // Avoid processing the same event twice. + if seen[ev] { + continue + } + seen[ev] = true + if s.isContentDirEvent(ev) { logger.Println("Source changed", ev.Name) sourceChanged = append(sourceChanged, ev)