From fc50f01de338d34054794a7451c25f8dab8a49ba Mon Sep 17 00:00:00 2001 From: sentriz Date: Sun, 14 Nov 2021 16:56:10 +0000 Subject: [PATCH] check ServeStream track errors --- server/ctrlsubsonic/handlers_raw.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/ctrlsubsonic/handlers_raw.go b/server/ctrlsubsonic/handlers_raw.go index 5ef831b..e3ba5f5 100644 --- a/server/ctrlsubsonic/handlers_raw.go +++ b/server/ctrlsubsonic/handlers_raw.go @@ -200,25 +200,25 @@ func (c *Controller) ServeStream(w http.ResponseWriter, r *http.Request) *spec.R var audioPath string switch id.Type { case specid.Track: - track, _ := streamGetTrack(c.DB, id.Value) - audioFile = track - audioPath = path.Join(track.AbsPath()) + track, err := streamGetTrack(c.DB, id.Value) if err != nil { return spec.NewError(70, "track with id `%s` was not found", id) } + audioFile = track + audioPath = path.Join(track.AbsPath()) case specid.PodcastEpisode: podcast, err := streamGetPodcast(c.DB, id.Value) - audioFile = podcast - audioPath = path.Join(c.PodcastsPath, podcast.Path) if err != nil { return spec.NewError(70, "podcast with id `%s` was not found", id) } + audioFile = podcast + audioPath = path.Join(c.PodcastsPath, podcast.Path) default: return spec.NewError(70, "media type of `%s` was not found", id.Type) } user := r.Context().Value(CtxUser).(*db.User) - if track, ok := audioFile.(*db.Track); ok { + if track, ok := audioFile.(*db.Track); ok && track.Album != nil { defer streamUpdateStats(c.DB, user.ID, track.Album.ID) }