Skip to content

Commit

Permalink
hugolib: Handle newly created files in Fast Render Mode
Browse files Browse the repository at this point in the history
Updates #4339
  • Loading branch information
yanzay authored and bep committed Jan 30, 2018
1 parent 2fa70c9 commit 1707dae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions hugolib/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ func (s *Site) timerStep(step string) {
type whatChanged struct {
source bool
other bool
files map[string]bool
}

// RegisterMediaTypes will register the Site's media types in the mime
Expand Down Expand Up @@ -640,6 +641,7 @@ func (s *Site) processPartial(events []fsnotify.Event) (whatChanged, error) {
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()
Expand Down Expand Up @@ -723,7 +725,7 @@ func (s *Site) processPartial(events []fsnotify.Event) (whatChanged, error) {
}

sourceReallyChanged = append(sourceReallyChanged, ev)

sourceFilesChanged[ev.Name] = true
}

for shortcode := range shortcodesChanged {
Expand Down Expand Up @@ -758,6 +760,7 @@ func (s *Site) processPartial(events []fsnotify.Event) (whatChanged, error) {
changed := whatChanged{
source: len(sourceChanged) > 0,
other: len(tmplChanged) > 0 || len(i18nChanged) > 0 || len(dataChanged) > 0,
files: sourceFilesChanged,
}

return changed, nil
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -1246,7 +1249,6 @@ func (c *contentCaptureResultHandler) handleCopyFiles(filenames ...string) {
}

func (s *Site) readAndProcessContent(filenames ...string) error {

ctx := context.Background()
g, ctx := errgroup.WithContext(ctx)

Expand Down
4 changes: 2 additions & 2 deletions hugolib/site_render.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

// 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)
Expand All @@ -50,7 +50,7 @@ func (s *Site) renderPages(filter map[string]bool) error {
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
Expand Down

0 comments on commit 1707dae

Please sign in to comment.