Fix inf values causing marshal error (#1607)

This commit is contained in:
WithoutPants
2021-08-03 14:29:57 +10:00
committed by GitHub
parent c7d2ddc5db
commit 8a7577c9bf
3 changed files with 15 additions and 2 deletions

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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))