refactor(artwork): fold Refresh into housekeeping

refresh.go was a 21-line file for one function that clears artwork state
and enqueues -- the same thing Backfill, EnqueueStaleAbsentAll and
EnqueueMissingAll already do next door.

Pure move.
This commit is contained in:
Deluan 2026-07-26 21:54:02 -04:00
parent f9b0717086
commit 85b5f2e76c
2 changed files with 13 additions and 21 deletions

View File

@ -123,3 +123,16 @@ func EnqueueMissingAll(ctx context.Context, ds model.DataStore) error {
}
return nil
}
// 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 model.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.Prefix(), 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
}

View File

@ -1,21 +0,0 @@
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 model.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.Prefix(), 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
}