From 36596d4fdb1edbe524f803553483e4366051c4a7 Mon Sep 17 00:00:00 2001 From: Deluan Date: Tue, 3 Nov 2020 16:06:02 -0500 Subject: [PATCH] Don't send the transcoded file if it is a HEAD request --- server/subsonic/stream.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/server/subsonic/stream.go b/server/subsonic/stream.go index e1369269..d6131ca3 100644 --- a/server/subsonic/stream.go +++ b/server/subsonic/stream.go @@ -3,6 +3,7 @@ package subsonic import ( "fmt" "io" + "io/ioutil" "net/http" "strconv" "strings" @@ -63,10 +64,14 @@ func (c *StreamController) Stream(w http.ResponseWriter, r *http.Request) (*resp w.Header().Set("Content-Length", length) } - if c, err := io.Copy(w, stream); err != nil { - log.Error(ctx, "Error sending transcoded file", "id", id, err) + if r.Method == "HEAD" { + go func() { _, _ = io.Copy(ioutil.Discard, stream) }() } else { - log.Trace(ctx, "Success sending transcode file", "id", id, "size", c) + if c, err := io.Copy(w, stream); err != nil { + log.Error(ctx, "Error sending transcoded file", "id", id, err) + } else { + log.Trace(ctx, "Success sending transcode file", "id", id, "size", c) + } } }