mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-08 18:37:09 +02:00
`artwork explain` rejected `dc` and `mf` because it validated against RecheckKinds, the list of kinds the backfill revisits. Those are different questions: a kind with no recheck path still has artwork someone can report as wrong. Disc artwork now walks DiscArtPriority under a trace, so explain reports which entry won and why the others lost, including entries that map to no source at all (external is unsupported, a disc with no subtitle, an album folder with no images). Media file artwork traces its single embedded candidate, separating "EnableMediaFileCoverArt is off" from "the track has no embedded art" — stored state cannot tell those apart. Each command now validates against the kinds it can actually serve: explain takes all six, refresh takes artwork.RefreshableKinds (which nativeapi now shares instead of keeping its own copy), reprocess still takes RecheckKinds. Disc artwork stays out of refresh: the worker cannot resolve it, so the queue row would be rejected on every drain. WalksPriorityChain becomes Explainable, and ResolveArtist/ResolveAlbum collapse into Resolve(kind, id).
34 lines
1 KiB
Go
34 lines
1 KiB
Go
package nativeapi
|
|
|
|
import (
|
|
"net/http"
|
|
"slices"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
"github.com/navidrome/navidrome/core/artwork"
|
|
"github.com/navidrome/navidrome/log"
|
|
"github.com/navidrome/navidrome/model"
|
|
)
|
|
|
|
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 !slices.Contains(artwork.RefreshableKinds, 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)
|
|
}
|
|
}
|