Fix server panic on i18n file change

Fixes #12048
This commit is contained in:
Bjørn Erik Pedersen 2024-02-17 11:09:09 +01:00
parent 2d1681d915
commit 9679443c15

View file

@ -739,7 +739,6 @@ func (h *HugoSites) processPartial(ctx context.Context, l logg.LevelLogger, conf
case files.ComponentFolderLayouts: case files.ComponentFolderLayouts:
tmplChanged = true tmplChanged = true
h.init.layouts.Reset()
templatePath := pathInfo.TrimLeadingSlash().PathNoLang() templatePath := pathInfo.TrimLeadingSlash().PathNoLang()
if !h.Tmpl().HasTemplate(templatePath) { if !h.Tmpl().HasTemplate(templatePath) {
tmplAdded = true tmplAdded = true
@ -899,6 +898,9 @@ func (h *HugoSites) processPartial(ctx context.Context, l logg.LevelLogger, conf
} }
if tmplChanged || i18nChanged { 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) { if err := loggers.TimeTrackfn(func() (logg.LevelLogger, error) {
// TODO(bep) this could probably be optimized to somehow // TODO(bep) this could probably be optimized to somehow
// only load the changed templates and its dependencies, but that is non-trivial. // only load the changed templates and its dependencies, but that is non-trivial.