diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-10-17 09:28:04 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-10-17 10:15:22 +0200 |
commit | 4a366fcfee24b3a5a5045b16c3b87b76147adf5e (patch) | |
tree | 7a8562579346a5dedb31137c896b6f5311ec061c /hugolib | |
parent | 083311d0336ced35909b3375950f7817ecf95ed0 (diff) |
Prevent stale content in Fast Render Mode
We do that by re-render visited pages that is not already in the stack. This may potentially do some double work, but that small penalty should be well worth it.
Fixes #5281
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/hugo_sites.go | 5 | ||||
-rw-r--r-- | hugolib/hugo_sites_build.go | 56 | ||||
-rw-r--r-- | hugolib/site_render.go | 2 |
3 files changed, 40 insertions, 23 deletions
diff --git a/hugolib/hugo_sites.go b/hugolib/hugo_sites.go index d9eb9f57d..7f70967d6 100644 --- a/hugolib/hugo_sites.go +++ b/hugolib/hugo_sites.go @@ -368,6 +368,11 @@ type BuildCfg struct { SkipRender bool // Use this to indicate what changed (for rebuilds). whatChanged *whatChanged + + // This is a partial re-render of some selected pages. This means + // we should skip most of the processing. + PartialReRender bool + // Recently visited URLs. This is used for partial re-rendering. RecentlyVisited map[string]bool } diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go index 5bb328aa2..13fbfd57e 100644 --- a/hugolib/hugo_sites_build.go +++ b/hugolib/hugo_sites_build.go @@ -41,27 +41,29 @@ func (h *HugoSites) Build(config BuildCfg, events ...fsnotify.Event) error { conf.whatChanged = &whatChanged{source: true, other: true} } - for _, s := range h.Sites { - s.Deps.BuildStartListeners.Notify() - } + if !config.PartialReRender { + for _, s := range h.Sites { + s.Deps.BuildStartListeners.Notify() + } - if len(events) > 0 { - // Rebuild - if err := h.initRebuild(conf); err != nil { - return err + if len(events) > 0 { + // Rebuild + if err := h.initRebuild(conf); err != nil { + return err + } + } else { + if err := h.init(conf); err != nil { + return err + } } - } else { - if err := h.init(conf); err != nil { + + if err := h.process(conf, events...); err != nil { return err } - } - if err := h.process(conf, events...); err != nil { - return err - } - - if err := h.assemble(conf); err != nil { - return err + if err := h.assemble(conf); err != nil { + return err + } } if err := h.render(conf); err != nil { @@ -226,8 +228,10 @@ func (h *HugoSites) assemble(config *BuildCfg) error { } func (h *HugoSites) render(config *BuildCfg) error { - for _, s := range h.Sites { - s.initRenderFormats() + if !config.PartialReRender { + for _, s := range h.Sites { + s.initRenderFormats() + } } for _, s := range h.Sites { @@ -240,15 +244,23 @@ func (h *HugoSites) render(config *BuildCfg) error { isRenderingSite := s == s2 - if err := s2.preparePagesForRender(isRenderingSite && i == 0); err != nil { - return err + if !config.PartialReRender { + if err := s2.preparePagesForRender(isRenderingSite && i == 0); err != nil { + return err + } } } if !config.SkipRender { - if err := s.render(config, i); err != nil { - return err + if config.PartialReRender { + if err := s.renderPages(config); err != nil { + return err + } + } else { + if err := s.render(config, i); err != nil { + return err + } } } } diff --git a/hugolib/site_render.go b/hugolib/site_render.go index 13fbb43cd..6583acd06 100644 --- a/hugolib/site_render.go +++ b/hugolib/site_render.go @@ -43,7 +43,7 @@ func (s *Site) renderPages(cfg *BuildCfg) error { go pageRenderer(s, pages, results, wg) } - if len(s.headlessPages) > 0 { + if !cfg.PartialReRender && len(s.headlessPages) > 0 { wg.Add(1) go headlessPagesPublisher(s, wg) } |