shithub: hugo

Download patch

ref: 1707dae8d3634006017eb6d040df4dbafc53d92f
parent: 2fa70c9344b231c9d999bbafdfa4acbf27ed9f6e
author: Alexey Grachov <[email protected]>
date: Sun Jan 28 07:46:48 EST 2018

hugolib: Handle newly created files in Fast Render Mode

Updates #4339

--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -536,6 +536,7 @@
 type whatChanged struct {
 	source bool
 	other  bool
+	files  map[string]bool
 }
 
 // RegisterMediaTypes will register the Site's media types in the mime
@@ -640,6 +641,7 @@
 		dataChanged         = []fsnotify.Event{}
 		i18nChanged         = []fsnotify.Event{}
 		shortcodesChanged   = make(map[string]bool)
+		sourceFilesChanged  = make(map[string]bool)
 
 		// prevent spamming the log on changes
 		logger = helpers.NewDistinctFeedbackLogger()
@@ -723,7 +725,7 @@
 		}
 
 		sourceReallyChanged = append(sourceReallyChanged, ev)
-
+		sourceFilesChanged[ev.Name] = true
 	}
 
 	for shortcode := range shortcodesChanged {
@@ -758,6 +760,7 @@
 	changed := whatChanged{
 		source: len(sourceChanged) > 0,
 		other:  len(tmplChanged) > 0 || len(i18nChanged) > 0 || len(dataChanged) > 0,
+		files:  sourceFilesChanged,
 	}
 
 	return changed, nil
@@ -938,7 +941,7 @@
 
 	}
 
-	if err = s.renderPages(config.RecentlyVisited); err != nil {
+	if err = s.renderPages(config.RecentlyVisited, config.whatChanged.files); err != nil {
 		return
 	}
 
@@ -1246,7 +1249,6 @@
 }
 
 func (s *Site) readAndProcessContent(filenames ...string) error {
-
 	ctx := context.Background()
 	g, ctx := errgroup.WithContext(ctx)
 
--- a/hugolib/site_render.go
+++ b/hugolib/site_render.go
@@ -24,7 +24,7 @@
 
 // renderPages renders pages each corresponding to a markdown file.
 // TODO(bep np doc
-func (s *Site) renderPages(filter map[string]bool) error {
+func (s *Site) renderPages(filter map[string]bool, files map[string]bool) error {
 
 	results := make(chan error)
 	pages := make(chan *Page)
@@ -50,7 +50,7 @@
 	hasFilter := filter != nil && len(filter) > 0
 
 	for _, page := range s.Pages {
-		if hasFilter && !filter[page.RelPermalink()] {
+		if hasFilter && !filter[page.RelPermalink()] && !files[page.Source.Filename()] {
 			continue
 		}
 		pages <- page