mirror of
https://github.com/navidrome/navidrome.git
synced 2026-08-01 07:21:17 +00:00
Comments only; no executable code changed. Verified by comparing the Go
token stream of every touched file before and after: identical.
Removes 375 of the 1104 comment lines this branch added, targeting content
that belongs in a commit message or PR body rather than in the code:
rejected alternatives ("DeleteIfUnchanged, not Delete", "Waking all beats
routing by kind"), refactor history ("as the legacy reader did"), issue
references (#5798, #5597, #5376), benchmark numbers (~400ms, ~16k allocs),
and four persistence doc comments that duplicated the interface godoc in
model/artwork.go verbatim.
Comments predating this branch are left untouched.
The ASCII fixture trees in the e2e suites are deliberately kept above the
line budget: they diagram the fixture layout with its expected outcomes,
and every pre-existing block in those files carries one.
42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
package nativeapi
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
"github.com/navidrome/navidrome/core/artwork"
|
|
"github.com/navidrome/navidrome/log"
|
|
"github.com/navidrome/navidrome/model"
|
|
)
|
|
|
|
var refreshableArtworkKinds = map[model.Kind]bool{
|
|
model.KindAlbumArtwork: true,
|
|
model.KindArtistArtwork: true,
|
|
model.KindPlaylistArtwork: true,
|
|
model.KindRadioArtwork: true,
|
|
model.KindMediaFileArtwork: true,
|
|
}
|
|
|
|
func (api *Router) addArtworkRoute(r chi.Router) {
|
|
r.Post("/artwork/{kind}/{id}/refresh", api.refreshArtwork())
|
|
}
|
|
|
|
// State is deliberately cleared so a wrong pick disappears immediately (placeholder until re-resolved).
|
|
func (api *Router) refreshArtwork() http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
ctx := r.Context()
|
|
kind, _ := model.ParseKind(chi.URLParam(r, "kind"))
|
|
id := chi.URLParam(r, "id")
|
|
if !refreshableArtworkKinds[kind] {
|
|
http.Error(w, "invalid artwork kind", http.StatusBadRequest)
|
|
return
|
|
}
|
|
if err := artwork.Refresh(ctx, api.ds, kind, id); err != nil {
|
|
log.Error(ctx, "Error refreshing artwork", "kind", kind, "id", id, err)
|
|
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
w.WriteHeader(http.StatusNoContent)
|
|
}
|
|
}
|