use path.Join to construct image cache path

This commit is contained in:
Duncan Overbruck
2020-07-24 17:09:22 +02:00
committed by Senan Kelly
parent ae98a18b52
commit 2e0efa7c7d

View File

@@ -68,8 +68,10 @@ func (c *Controller) ServeGetCoverArt(w http.ResponseWriter, r *http.Request) *s
return spec.NewError(10, "please provide an `id` parameter")
}
size := params.GetOrInt("size", coverDefaultSize)
cacheFile := fmt.Sprintf("%s/%s-%d.%s", c.CachePath, id.String(), size,
coverCacheFormat)
cacheFile := path.Join(
c.CachePath,
fmt.Sprintf("%s-%d.%s", id.String(), size, coverCacheFormat),
)
_, err = os.Stat(cacheFile)
if os.IsNotExist(err) {
log.Printf("serving cover `%s`: cache [%s/%d] miss!\n",