aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-10-23 19:26:13 +0200
committerBjørn Erik Pedersen <[email protected]>2024-10-24 13:34:11 +0200
commitcb6e27b32a1d09956027b8e45bae0c18c1593d5c (patch)
treebd3031431175596ddfad3a79daf69563f723ac6f /hugolib
parent5bbe95f9c5442898cdfb100bff4f1aac52fce5ad (diff)
downloadhugo-cb6e27b32a1d09956027b8e45bae0c18c1593d5c.tar.gz
hugo-cb6e27b32a1d09956027b8e45bae0c18c1593d5c.zip
hugolib/commands: Fix stuck server error issues
Fixes #11378
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/hugo_sites.go3
-rw-r--r--hugolib/hugo_sites_build.go10
-rw-r--r--hugolib/integrationtest_builder.go5
-rw-r--r--hugolib/page__new.go13
-rw-r--r--hugolib/site.go10
5 files changed, 9 insertions, 32 deletions
diff --git a/hugolib/hugo_sites.go b/hugolib/hugo_sites.go
index 659a772f2..a5186fd44 100644
--- a/hugolib/hugo_sites.go
+++ b/hugolib/hugo_sites.go
@@ -179,9 +179,6 @@ type hugoSitesInit struct {
// Loads the data from all of the /data folders.
data *lazy.Init
- // Performs late initialization (before render) of the templates.
- layouts *lazy.Init
-
// Loads the Git info and CODEOWNERS for all the pages if enabled.
gitInfo *lazy.Init
}
diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go
index 65ce946e9..dd548be51 100644
--- a/hugolib/hugo_sites_build.go
+++ b/hugolib/hugo_sites_build.go
@@ -250,10 +250,6 @@ func (h *HugoSites) process(ctx context.Context, l logg.LevelLogger, config *Bui
l = l.WithField("step", "process")
defer loggers.TimeTrackf(l, time.Now(), nil, "")
- if _, err := h.init.layouts.Do(ctx); err != nil {
- return err
- }
-
if len(events) > 0 {
// This is a rebuild triggered from file events.
return h.processPartialFileEvents(ctx, l, config, init, events)
@@ -1067,8 +1063,6 @@ func (h *HugoSites) processPartialFileEvents(ctx context.Context, l logg.LevelLo
}
if tmplChanged || i18nChanged {
- // TODO(bep) we should split this, but currently the loading of i18n and layout files are tied together. See #12048.
- h.init.layouts.Reset()
if err := loggers.TimeTrackfn(func() (logg.LevelLogger, error) {
// TODO(bep) this could probably be optimized to somehow
// only load the changed templates and its dependencies, but that is non-trivial.
@@ -1141,10 +1135,6 @@ func (s *Site) handleContentAdapterChanges(bi pagesfromdata.BuildInfo, buildConf
}
func (h *HugoSites) processContentAdaptersOnRebuild(ctx context.Context, buildConfig *BuildCfg) error {
- // Make sure the layouts are initialized.
- if _, err := h.init.layouts.Do(context.Background()); err != nil {
- return err
- }
g := rungroup.Run[*pagesfromdata.PagesFromTemplate](ctx, rungroup.Config[*pagesfromdata.PagesFromTemplate]{
NumWorkers: h.numWorkers,
Handle: func(ctx context.Context, p *pagesfromdata.PagesFromTemplate) error {
diff --git a/hugolib/integrationtest_builder.go b/hugolib/integrationtest_builder.go
index b45defb42..b806ad7c1 100644
--- a/hugolib/integrationtest_builder.go
+++ b/hugolib/integrationtest_builder.go
@@ -246,11 +246,6 @@ func (s *IntegrationTestBuilder) AssertBuildCountGitInfo(count int) {
s.Assert(s.H.init.gitInfo.InitCount(), qt.Equals, count)
}
-func (s *IntegrationTestBuilder) AssertBuildCountLayouts(count int) {
- s.Helper()
- s.Assert(s.H.init.layouts.InitCount(), qt.Equals, count)
-}
-
func (s *IntegrationTestBuilder) AssertFileCount(dirname string, expected int) {
s.Helper()
fs := s.fs.WorkingDirReadOnly
diff --git a/hugolib/page__new.go b/hugolib/page__new.go
index b7d9b10f2..9a4972d07 100644
--- a/hugolib/page__new.go
+++ b/hugolib/page__new.go
@@ -34,6 +34,15 @@ import (
var pageIDCounter atomic.Uint64
func (h *HugoSites) newPage(m *pageMeta) (*pageState, *paths.Path, error) {
+ p, pth, err := h.doNewPage(m)
+ if err != nil {
+ // Make sure that any partially created page part is marked as stale.
+ m.MarkStale()
+ }
+ return p, pth, err
+}
+
+func (h *HugoSites) doNewPage(m *pageMeta) (*pageState, *paths.Path, error) {
m.Staler = &resources.AtomicStaler{}
if m.pageMetaParams == nil {
m.pageMetaParams = &pageMetaParams{
@@ -231,10 +240,6 @@ func (h *HugoSites) newPage(m *pageMeta) (*pageState, *paths.Path, error) {
}
return ps, nil
}()
- // Make sure to evict any cached and now stale data.
- if err != nil {
- m.MarkStale()
- }
if ps == nil {
return nil, nil, err
diff --git a/hugolib/site.go b/hugolib/site.go
index 08031390b..24ee5dcc5 100644
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -344,7 +344,6 @@ func newHugoSites(cfg deps.DepsCfg, d *deps.Deps, pageTrees *pageTrees, sites []
skipRebuildForFilenames: make(map[string]bool),
init: &hugoSitesInit{
data: lazy.New(),
- layouts: lazy.New(),
gitInfo: lazy.New(),
},
}
@@ -400,15 +399,6 @@ func newHugoSites(cfg deps.DepsCfg, d *deps.Deps, pageTrees *pageTrees, sites []
return nil, nil
})
- h.init.layouts.Add(func(context.Context) (any, error) {
- for _, s := range h.Sites {
- if err := s.Tmpl().(tpl.TemplateManager).MarkReady(); err != nil {
- return nil, err
- }
- }
- return nil, nil
- })
-
h.init.gitInfo.Add(func(context.Context) (any, error) {
err := h.loadGitInfo()
if err != nil {