🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Do not empty old artist metadata (#2423)
Kendall Garner79870b1090bb
diff --git a/model/artist.go b/model/artist.goindex 1a3ba4968..f6bb33f49 100644--- a/model/artist.go+++ b/model/artist.go@@ -49,7 +49,7 @@ type ArtistIndexes []ArtistIndextype ArtistRepository interface {CountAll(options ...QueryOptions) (int64, error)Exists(id string) (bool, error)- Put(m *Artist) error+ Put(m *Artist, colsToUpdate ...string) errorGet(id string) (*Artist, error)GetAll(options ...QueryOptions) (Artists, error)Search(q string, offset int, size int) (Artists, error)diff --git a/persistence/artist_repository.go b/persistence/artist_repository.goindex bd3a506b9..e4a0a0f76 100644--- a/persistence/artist_repository.go+++ b/persistence/artist_repository.go@@ -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}diff --git a/scanner/refresher.go b/scanner/refresher.goindex 2d8a8da55..ec17fc1e6 100644--- a/scanner/refresher.go+++ b/scanner/refresher.go@@ -142,7 +142,8 @@ func (r *refresher) refreshArtists(ctx context.Context, ids ...string) error {// Force a external metadata lookup on next accessa.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}diff --git a/tests/mock_artist_repo.go b/tests/mock_artist_repo.goindex 6f30679fb..aa0a83f3e 100644--- a/tests/mock_artist_repo.go+++ b/tests/mock_artist_repo.go@@ -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")}