hugolib: Handle newly created files in Fast Render Mode

Updates #4339
This commit is contained in:
Alexey Grachov 2018-01-28 12:46:48 +02:00 committed by Bjørn Erik Pedersen
parent 2fa70c9344
commit 1707dae8d3
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F
2 changed files with 7 additions and 5 deletions

View file

@ -536,6 +536,7 @@ func (s *Site) timerStep(step string) {
type whatChanged struct { type whatChanged struct {
source bool source bool
other bool other bool
files map[string]bool
} }
// RegisterMediaTypes will register the Site's media types in the mime // RegisterMediaTypes will register the Site's media types in the mime
@ -640,6 +641,7 @@ func (s *Site) processPartial(events []fsnotify.Event) (whatChanged, error) {
dataChanged = []fsnotify.Event{} dataChanged = []fsnotify.Event{}
i18nChanged = []fsnotify.Event{} i18nChanged = []fsnotify.Event{}
shortcodesChanged = make(map[string]bool) shortcodesChanged = make(map[string]bool)
sourceFilesChanged = make(map[string]bool)
// prevent spamming the log on changes // prevent spamming the log on changes
logger = helpers.NewDistinctFeedbackLogger() logger = helpers.NewDistinctFeedbackLogger()
@ -723,7 +725,7 @@ func (s *Site) processPartial(events []fsnotify.Event) (whatChanged, error) {
} }
sourceReallyChanged = append(sourceReallyChanged, ev) sourceReallyChanged = append(sourceReallyChanged, ev)
sourceFilesChanged[ev.Name] = true
} }
for shortcode := range shortcodesChanged { for shortcode := range shortcodesChanged {
@ -758,6 +760,7 @@ func (s *Site) processPartial(events []fsnotify.Event) (whatChanged, error) {
changed := whatChanged{ changed := whatChanged{
source: len(sourceChanged) > 0, source: len(sourceChanged) > 0,
other: len(tmplChanged) > 0 || len(i18nChanged) > 0 || len(dataChanged) > 0, other: len(tmplChanged) > 0 || len(i18nChanged) > 0 || len(dataChanged) > 0,
files: sourceFilesChanged,
} }
return changed, nil return changed, nil
@ -938,7 +941,7 @@ func (s *Site) render(config *BuildCfg, outFormatIdx int) (err error) {
} }
if err = s.renderPages(config.RecentlyVisited); err != nil { if err = s.renderPages(config.RecentlyVisited, config.whatChanged.files); err != nil {
return return
} }
@ -1246,7 +1249,6 @@ func (c *contentCaptureResultHandler) handleCopyFiles(filenames ...string) {
} }
func (s *Site) readAndProcessContent(filenames ...string) error { func (s *Site) readAndProcessContent(filenames ...string) error {
ctx := context.Background() ctx := context.Background()
g, ctx := errgroup.WithContext(ctx) g, ctx := errgroup.WithContext(ctx)

View file

@ -24,7 +24,7 @@ import (
// renderPages renders pages each corresponding to a markdown file. // renderPages renders pages each corresponding to a markdown file.
// TODO(bep np doc // 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) results := make(chan error)
pages := make(chan *Page) pages := make(chan *Page)
@ -50,7 +50,7 @@ func (s *Site) renderPages(filter map[string]bool) error {
hasFilter := filter != nil && len(filter) > 0 hasFilter := filter != nil && len(filter) > 0
for _, page := range s.Pages { for _, page := range s.Pages {
if hasFilter && !filter[page.RelPermalink()] { if hasFilter && !filter[page.RelPermalink()] && !files[page.Source.Filename()] {
continue continue
} }
pages <- page pages <- page