diff options
author | Bjørn Erik Pedersen <[email protected]> | 2018-05-08 10:10:13 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2018-05-08 16:52:51 +0200 |
commit | 086ae81a98149de6b220cc7e2f155d15f0bc17e3 (patch) | |
tree | 3784e998e8fa52bae70e3c5737e3acaf6b865897 /hugolib/site_render.go | |
parent | c2bb62d63eb17e00b692b56f0ef2abf7db6009cf (diff) | |
download | hugo-086ae81a98149de6b220cc7e2f155d15f0bc17e3.tar.gz hugo-086ae81a98149de6b220cc7e2f155d15f0bc17e3.zip |
hugolib: Fix possible .Content cut
There have been one report of a site with truncated `.Content` after the Hugo `0.40.1` release.
This commit fixes this so that race should not be possible anymore. It also adds a stress test with focus on content rendering and multiple output formats.
Fixes #4706
Diffstat (limited to 'hugolib/site_render.go')
-rw-r--r-- | hugolib/site_render.go | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/hugolib/site_render.go b/hugolib/site_render.go index e9d2f0183..e837d9f0b 100644 --- a/hugolib/site_render.go +++ b/hugolib/site_render.go @@ -73,7 +73,7 @@ func headlessPagesPublisher(s *Site, wg *sync.WaitGroup) { // Avoid double work. continue } - pageOutput, err := newPageOutput(page, false, outFormat) + pageOutput, err := newPageOutput(page, false, false, outFormat) if err == nil { page.mainPageOutput = pageOutput err = pageOutput.renderResources() @@ -92,28 +92,29 @@ func pageRenderer(s *Site, pages <-chan *Page, results chan<- error, wg *sync.Wa for i, outFormat := range page.outputFormats { + if outFormat != page.s.rc.Format { + // Will be rendered ... later. + continue + } + var ( pageOutput *PageOutput err error ) if i == 0 { - pageOutput, err = newPageOutput(page, false, outFormat) - page.mainPageOutput = pageOutput + pageOutput = page.mainPageOutput + } else { + pageOutput, err = page.mainPageOutput.copyWithFormat(outFormat, true) } - if outFormat != page.s.rc.Format { - // Will be rendered ... later. + if err != nil { + s.Log.ERROR.Printf("Failed to create output page for type %q for page %q: %s", outFormat.Name, page, err) continue } if pageOutput == nil { - pageOutput, err = page.mainPageOutput.copyWithFormat(outFormat) - } - - if err != nil { - s.Log.ERROR.Printf("Failed to create output page for type %q for page %q: %s", outFormat.Name, page, err) - continue + panic("no pageOutput") } // We only need to re-publish the resources if the output format is different @@ -291,7 +292,7 @@ func (s *Site) render404() error { htmlOut := output.HTMLFormat htmlOut.BaseName = "404" - pageOutput, err := newPageOutput(p, false, htmlOut) + pageOutput, err := newPageOutput(p, false, false, htmlOut) if err != nil { return err } @@ -373,7 +374,7 @@ func (s *Site) renderRobotsTXT() error { rLayouts := []string{"robots.txt", "_default/robots.txt", "_internal/_default/robots.txt"} - pageOutput, err := newPageOutput(p, false, output.RobotsTxtFormat) + pageOutput, err := newPageOutput(p, false, false, output.RobotsTxtFormat) if err != nil { return err } |