From 212a13395d288486f9baa57c2da9bef2d9b6324d Mon Sep 17 00:00:00 2001 From: sentriz Date: Mon, 23 Aug 2021 21:31:49 +0100 Subject: [PATCH] fix: return early before type switch in ServeStream related #152 --- server/ctrlsubsonic/handlers_raw.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/server/ctrlsubsonic/handlers_raw.go b/server/ctrlsubsonic/handlers_raw.go index 9f6a9a2a..776a0007 100644 --- a/server/ctrlsubsonic/handlers_raw.go +++ b/server/ctrlsubsonic/handlers_raw.go @@ -212,17 +212,16 @@ func (c *Controller) ServeStream(w http.ResponseWriter, r *http.Request) *spec.R if err != nil { return spec.NewError(70, "podcast with id `%s` was not found", id) } + default: + return spec.NewError(70, "media type of `%s` was not found", id.Type) } - if err != nil && id.Type != specid.Podcast { - return spec.NewError(70, "media with id `%d` was not found", id.Value) - } user := r.Context().Value(CtxUser).(*db.User) if track, ok := audioFile.(*db.Track); ok { defer streamUpdateStats(c.DB, user.ID, track.Album.ID) } + pref := streamGetTransPref(c.DB, user.ID, params.GetOr("c", "")) - // onInvalidProfile := func() error { log.Printf("serving raw `%s`\n", audioFile.AudioFilename()) w.Header().Set("Content-Type", audioFile.MIME())