mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-27 14:59:28 +01:00
Fix int types in OpenSubsonic responses.
Refer to https://support.symfonium.app/t/symfonium-sync-crashes-when-tpos-is-not-an-int/4204
This commit is contained in:
parent
7ab7b5df5e
commit
2c06a4234e
4 changed files with 39 additions and 14 deletions
|
|
@ -7,7 +7,6 @@ import (
|
|||
"mime"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/navidrome/navidrome/consts"
|
||||
|
|
@ -15,6 +14,7 @@ import (
|
|||
"github.com/navidrome/navidrome/model/request"
|
||||
"github.com/navidrome/navidrome/server/public"
|
||||
"github.com/navidrome/navidrome/server/subsonic/responses"
|
||||
"github.com/navidrome/navidrome/utils/number"
|
||||
)
|
||||
|
||||
func newResponse() *responses.Subsonic {
|
||||
|
|
@ -254,12 +254,12 @@ func toItemDate(date string) responses.ItemDate {
|
|||
}
|
||||
parts := strings.Split(date, "-")
|
||||
if len(parts) > 2 {
|
||||
itemDate.Day, _ = strconv.Atoi(parts[2])
|
||||
itemDate.Day = number.ParseInt[int32](parts[2])
|
||||
}
|
||||
if len(parts) > 1 {
|
||||
itemDate.Month, _ = strconv.Atoi(parts[1])
|
||||
itemDate.Month = number.ParseInt[int32](parts[1])
|
||||
}
|
||||
itemDate.Year, _ = strconv.Atoi(parts[0])
|
||||
itemDate.Year = number.ParseInt[int32](parts[0])
|
||||
|
||||
return itemDate
|
||||
}
|
||||
|
|
@ -278,7 +278,7 @@ func buildDiscSubtitles(_ context.Context, a model.Album) responses.DiscTitles {
|
|||
}
|
||||
discTitles := responses.DiscTitles{}
|
||||
for num, title := range a.Discs {
|
||||
discTitles = append(discTitles, responses.DiscTitle{Disc: num, Title: title})
|
||||
discTitles = append(discTitles, responses.DiscTitle{Disc: int32(num), Title: title})
|
||||
}
|
||||
sort.Slice(discTitles, func(i, j int) bool {
|
||||
return discTitles[i].Disc < discTitles[j].Disc
|
||||
|
|
|
|||
|
|
@ -502,7 +502,7 @@ type ReplayGain struct {
|
|||
}
|
||||
|
||||
type DiscTitle struct {
|
||||
Disc int `xml:"disc,attr" json:"disc"`
|
||||
Disc int32 `xml:"disc,attr" json:"disc"`
|
||||
Title string `xml:"title,attr" json:"title"`
|
||||
}
|
||||
|
||||
|
|
@ -523,7 +523,7 @@ func marshalJSONArray[T any](v []T) ([]byte, error) {
|
|||
}
|
||||
|
||||
type ItemDate struct {
|
||||
Year int `xml:"year,attr,omitempty" json:"year,omitempty"`
|
||||
Month int `xml:"month,attr,omitempty" json:"month,omitempty"`
|
||||
Day int `xml:"day,attr,omitempty" json:"day,omitempty"`
|
||||
Year int32 `xml:"year,attr,omitempty" json:"year,omitempty"`
|
||||
Month int32 `xml:"month,attr,omitempty" json:"month,omitempty"`
|
||||
Day int32 `xml:"day,attr,omitempty" json:"day,omitempty"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue