Skip to content

Commit

Permalink
hugolib: Fix timeout number parsing for YAML/JSON config
Browse files Browse the repository at this point in the history
Where numbers are all floats.

Fixes #6555
  • Loading branch information
bep committed Nov 29, 2019
1 parent 003ba5b commit b60ae35
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions hugolib/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestImageOps(t *testing.T) {
c.Assert(err, qt.IsNil)
defer clean()

newBuilder := func(timeout string) *sitesBuilder {
newBuilder := func(timeout interface{}) *sitesBuilder {

v := viper.New()
v.Set("workingDir", workDir)
Expand Down Expand Up @@ -152,7 +152,7 @@ IMG SHORTCODE: /images/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_129x239_r
c.Assert(err, qt.Not(qt.IsNil))
}

b = newBuilder("30s")
b = newBuilder(29000)
b.Build(BuildCfg{})

assertImages()
Expand Down
10 changes: 5 additions & 5 deletions hugolib/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,11 @@ func newSite(cfg deps.DepsCfg) (*Site, error) {

timeout := 30 * time.Second
if cfg.Language.IsSet("timeout") {
switch v := cfg.Language.Get("timeout").(type) {
case int64:
timeout = time.Duration(v) * time.Millisecond
case string:
d, err := time.ParseDuration(v)
v := cfg.Language.Get("timeout")
if n := cast.ToInt(v); n > 0 {
timeout = time.Duration(n) * time.Millisecond
} else {
d, err := time.ParseDuration(cast.ToString(v))
if err == nil {
timeout = d
}
Expand Down

0 comments on commit b60ae35

Please sign in to comment.