Skip to content

Commit

Permalink
Fix inf values causing marshal error (#1607)
Browse files Browse the repository at this point in the history
  • Loading branch information
WithoutPants authored Aug 3, 2021
1 parent c7d2ddc commit 8a7577c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/api/resolver_model_scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ func (r *sceneResolver) File(ctx context.Context, obj *models.Scene) (*models.Sc
bitrate := int(obj.Bitrate.Int64)
return &models.SceneFileType{
Size: &obj.Size.String,
Duration: &obj.Duration.Float64,
Duration: handleFloat64(obj.Duration.Float64),
VideoCodec: &obj.VideoCodec.String,
AudioCodec: &obj.AudioCodec.String,
Width: &width,
Height: &height,
Framerate: &obj.Framerate.Float64,
Framerate: handleFloat64(obj.Framerate.Float64),
Bitrate: &bitrate,
}, nil
}
Expand Down
12 changes: 12 additions & 0 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
package api

import "math"

// An enum https://golang.org/ref/spec#Iota
const (
create = iota // 0
update = iota // 1
)

// #1572 - Inf and NaN values cause the JSON marshaller to fail
// Return nil for these values
func handleFloat64(v float64) *float64 {
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil
}

return &v
}
1 change: 1 addition & 0 deletions ui/v2.5/src/components/Changelog/versions/v090.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Added de-DE language option. ([#1578](https://github.com/stashapp/stash/pull/1578))

### 🐛 Bug fixes
* Fix infinity framerate values causing resolver error. ([#1607](https://github.com/stashapp/stash/pull/1607))
* Fix unsetting performer gender not working correctly. ([#1606](https://github.com/stashapp/stash/pull/1606))
* Fix is missing date scene criterion causing invalid SQL. ([#1577](https://github.com/stashapp/stash/pull/1577))
* Fix rendering of carousel images on Apple devices. ([#1562](https://github.com/stashapp/stash/pull/1562))
Expand Down

0 comments on commit 8a7577c

Please sign in to comment.