mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Fix inf values causing marshal error (#1607)
This commit is contained in:
@@ -67,12 +67,12 @@ func (r *sceneResolver) File(ctx context.Context, obj *models.Scene) (*models.Sc
|
|||||||
bitrate := int(obj.Bitrate.Int64)
|
bitrate := int(obj.Bitrate.Int64)
|
||||||
return &models.SceneFileType{
|
return &models.SceneFileType{
|
||||||
Size: &obj.Size.String,
|
Size: &obj.Size.String,
|
||||||
Duration: &obj.Duration.Float64,
|
Duration: handleFloat64(obj.Duration.Float64),
|
||||||
VideoCodec: &obj.VideoCodec.String,
|
VideoCodec: &obj.VideoCodec.String,
|
||||||
AudioCodec: &obj.AudioCodec.String,
|
AudioCodec: &obj.AudioCodec.String,
|
||||||
Width: &width,
|
Width: &width,
|
||||||
Height: &height,
|
Height: &height,
|
||||||
Framerate: &obj.Framerate.Float64,
|
Framerate: handleFloat64(obj.Framerate.Float64),
|
||||||
Bitrate: &bitrate,
|
Bitrate: &bitrate,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,19 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
|
import "math"
|
||||||
|
|
||||||
// An enum https://golang.org/ref/spec#Iota
|
// An enum https://golang.org/ref/spec#Iota
|
||||||
const (
|
const (
|
||||||
create = iota // 0
|
create = iota // 0
|
||||||
update = iota // 1
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
* Added de-DE language option. ([#1578](https://github.com/stashapp/stash/pull/1578))
|
* Added de-DE language option. ([#1578](https://github.com/stashapp/stash/pull/1578))
|
||||||
|
|
||||||
### 🐛 Bug fixes
|
### 🐛 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 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 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))
|
* Fix rendering of carousel images on Apple devices. ([#1562](https://github.com/stashapp/stash/pull/1562))
|
||||||
|
|||||||
Reference in New Issue
Block a user