mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-16 20:53:59 +02:00
cache: Apply httpcache defaults for polling config
Previously, compiling the config with partial or missing poll configs would introduce a panic. This ensures that the default poll configs are applied in such scenarios to ensure config is valid. Fixes #13471
This commit is contained in:
13
cache/httpcache/httpcache.go
vendored
13
cache/httpcache/httpcache.go
vendored
@@ -188,7 +188,7 @@ func (gm *GlobMatcher) CompilePredicate() (func(string) bool, error) {
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func DecodeConfig(bcfg config.BaseConfig, m map[string]any) (Config, error) {
|
||||
func DecodeConfig(_ config.BaseConfig, m map[string]any) (Config, error) {
|
||||
if len(m) == 0 {
|
||||
return DefaultConfig, nil
|
||||
}
|
||||
@@ -214,5 +214,16 @@ func DecodeConfig(bcfg config.BaseConfig, m map[string]any) (Config, error) {
|
||||
c.Cache.For = DefaultConfig.Cache.For
|
||||
}
|
||||
|
||||
for pci := range c.Polls {
|
||||
if c.Polls[pci].For.IsZero() {
|
||||
c.Polls[pci].For = DefaultConfig.Cache.For
|
||||
c.Polls[pci].Disable = true
|
||||
}
|
||||
}
|
||||
|
||||
if len(c.Polls) == 0 {
|
||||
c.Polls = DefaultConfig.Polls
|
||||
}
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user