mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-02 17:33:17 +00:00
hugolib: Fix timeout number parsing for YAML/JSON config
Where numbers are all floats. Fixes #6555
This commit is contained in:
parent
003ba5b10f
commit
b60ae35b97
2 changed files with 7 additions and 7 deletions
hugolib
|
@ -36,7 +36,7 @@ func TestImageOps(t *testing.T) {
|
||||||
c.Assert(err, qt.IsNil)
|
c.Assert(err, qt.IsNil)
|
||||||
defer clean()
|
defer clean()
|
||||||
|
|
||||||
newBuilder := func(timeout string) *sitesBuilder {
|
newBuilder := func(timeout interface{}) *sitesBuilder {
|
||||||
|
|
||||||
v := viper.New()
|
v := viper.New()
|
||||||
v.Set("workingDir", workDir)
|
v.Set("workingDir", workDir)
|
||||||
|
@ -152,7 +152,7 @@ IMG SHORTCODE: /images/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_129x239_r
|
||||||
c.Assert(err, qt.Not(qt.IsNil))
|
c.Assert(err, qt.Not(qt.IsNil))
|
||||||
}
|
}
|
||||||
|
|
||||||
b = newBuilder("30s")
|
b = newBuilder(29000)
|
||||||
b.Build(BuildCfg{})
|
b.Build(BuildCfg{})
|
||||||
|
|
||||||
assertImages()
|
assertImages()
|
||||||
|
|
|
@ -413,11 +413,11 @@ func newSite(cfg deps.DepsCfg) (*Site, error) {
|
||||||
|
|
||||||
timeout := 30 * time.Second
|
timeout := 30 * time.Second
|
||||||
if cfg.Language.IsSet("timeout") {
|
if cfg.Language.IsSet("timeout") {
|
||||||
switch v := cfg.Language.Get("timeout").(type) {
|
v := cfg.Language.Get("timeout")
|
||||||
case int64:
|
if n := cast.ToInt(v); n > 0 {
|
||||||
timeout = time.Duration(v) * time.Millisecond
|
timeout = time.Duration(n) * time.Millisecond
|
||||||
case string:
|
} else {
|
||||||
d, err := time.ParseDuration(v)
|
d, err := time.ParseDuration(cast.ToString(v))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
timeout = d
|
timeout = d
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue