Skip to content

Commit

Permalink
hugolib: Avoid processing the same notify event twice
Browse files Browse the repository at this point in the history
On `macOS`, at least, we've seen multiple WRITE events for same file, and no need to do the same job twice.
  • Loading branch information
bep committed Apr 12, 2017
1 parent 5fad8a9 commit 3b67759
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions hugolib/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3b67759

Please sign in to comment.