diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2024-05-30 14:58:05 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2024-05-30 16:22:26 +0200 |
commit | 1464091ad639aa8d3a3793515a9661eaf801cfcb (patch) | |
tree | 651010ebafde1d5aabb3a476ebd692806568497c /hugolib/hugo_sites_build.go | |
parent | 2c88e454d8befa243a0e9e55ff92821d96865151 (diff) |
content adapter: Fix server crash on partial edit
Fixes #12538
Diffstat (limited to 'hugolib/hugo_sites_build.go')
-rw-r--r-- | hugolib/hugo_sites_build.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go index 4bea93039..8a4966055 100644 --- a/hugolib/hugo_sites_build.go +++ b/hugolib/hugo_sites_build.go @@ -239,6 +239,10 @@ 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 return h.processPartial(ctx, l, config, init, events) @@ -324,10 +328,6 @@ func (h *HugoSites) render(l logg.LevelLogger, config *BuildCfg) error { loggers.TimeTrackf(l, start, h.buildCounters.loggFields(), "") }() - if _, err := h.init.layouts.Do(context.Background()); err != nil { - return err - } - siteRenderContext := &siteRenderContext{cfg: config, multihost: h.Configs.IsMultihost} i := 0 @@ -918,7 +918,6 @@ func (h *HugoSites) processPartial(ctx context.Context, l logg.LevelLogger, conf 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. @@ -991,6 +990,10 @@ 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 { |