Skip to content

Commit 3b67759

Browse files
committed
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.
1 parent 5fad8a9 commit 3b67759

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

‎hugolib/site.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,15 @@ func (s *Site) reProcess(events []fsnotify.Event) (whatChanged, error) {
633633
shortcodesChanged := make(map[string]bool)
634634
// prevent spamming the log on changes
635635
logger := helpers.NewDistinctFeedbackLogger()
636+
seen := make(map[fsnotify.Event]bool)
636637

637638
for _, ev := range events {
639+
// Avoid processing the same event twice.
640+
if seen[ev] {
641+
continue
642+
}
643+
seen[ev] = true
644+
638645
if s.isContentDirEvent(ev) {
639646
logger.Println("Source changed", ev.Name)
640647
sourceChanged = append(sourceChanged, ev)

0 commit comments

Comments
 (0)