mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-05 01:38:51 +01:00
Relocate the image-upload service from core to core/artwork as artwork.Uploader, co-locating it with the resolver/worker/serving that own the artwork state it invalidates. MaxImageUploadSize moves too — its only callers are the two image-upload handlers — which lets core/image_upload.go be deleted entirely. Extract the shared "clear resolved state + re-queue at Bump" invalidation into artwork.Refresh and fold nativeapi's refreshArtwork handler onto it, removing the duplicated DeleteForItem+Enqueue block that had drifted into three places. The wire provider moves from core's set to artwork's; the playlists.ImageUploadService binding moves to the top-level injector so core/artwork stays unaware of playlists. Behavior is unchanged.
21 lines
749 B
Go
21 lines
749 B
Go
package artwork
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/navidrome/navidrome/model"
|
|
)
|
|
|
|
// Refresh clears an item's resolved artwork state and re-queues it at Bump priority, so a
|
|
// deliberate refresh (image upload or manual re-resolve) drops the current pick and re-resolves it.
|
|
func Refresh(ctx context.Context, ds model.DataStore, kind, id string) error {
|
|
if err := ds.Artwork(ctx).DeleteForItem(kind, id); err != nil {
|
|
return fmt.Errorf("clearing artwork state: %w", err)
|
|
}
|
|
item := model.ArtworkQueueItem{ItemKind: kind, ItemID: id, ImageType: model.ImageTypePrimary, Priority: model.ArtworkPriorityBump}
|
|
if err := ds.ArtworkQueue(ctx).Enqueue(item); err != nil {
|
|
return fmt.Errorf("enqueuing artwork refresh: %w", err)
|
|
}
|
|
return nil
|
|
}
|