Do not empty old artist metadata (#2423)

This commit is contained in:
Kendall Garner 2023-11-17 00:20:37 +00:00 committed by GitHub
parent 7a858a2db3
commit 79870b1090
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 5 deletions

View File

@ -49,7 +49,7 @@ type ArtistIndexes []ArtistIndex
type ArtistRepository interface {
CountAll(options ...QueryOptions) (int64, error)
Exists(id string) (bool, error)
Put(m *Artist) error
Put(m *Artist, colsToUpdate ...string) error
Get(id string) (*Artist, error)
GetAll(options ...QueryOptions) (Artists, error)
Search(q string, offset int, size int) (Artists, error)

View File

@ -60,10 +60,10 @@ func (r *artistRepository) Exists(id string) (bool, error) {
return r.exists(Select().Where(Eq{"artist.id": id}))
}
func (r *artistRepository) Put(a *model.Artist) error {
func (r *artistRepository) Put(a *model.Artist, colsToUpdate ...string) error {
a.FullText = getFullText(a.Name, a.SortArtistName)
dba := r.fromModel(a)
_, err := r.put(dba.ID, dba)
_, err := r.put(dba.ID, dba, colsToUpdate...)
if err != nil {
return err
}

View File

@ -142,7 +142,8 @@ func (r *refresher) refreshArtists(ctx context.Context, ids ...string) error {
// Force a external metadata lookup on next access
a.ExternalInfoUpdatedAt = time.Time{}
err := repo.Put(&a)
// Do not remove old metadata
err := repo.Put(&a, "album_count", "genres", "external_info_updated_at", "mbz_artist_id", "name", "order_artist_name", "size", "sort_artist_name", "song_count")
if err != nil {
return err
}

View File

@ -50,7 +50,7 @@ func (m *MockArtistRepo) Get(id string) (*model.Artist, error) {
return nil, model.ErrNotFound
}
func (m *MockArtistRepo) Put(ar *model.Artist) error {
func (m *MockArtistRepo) Put(ar *model.Artist, columsToUpdate ...string) error {
if m.err {
return errors.New("error")
}