Skip to content

🎧 Your Personal Streaming Service

Do not empty old artist metadata (#2423)

Kendall Garner79870b1090bb
diff --git a/model/artist.go b/model/artist.go
index 1a3ba4968..f6bb33f49 100644
--- a/model/artist.go
+++ b/model/artist.go
@@ -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)
diff --git a/persistence/artist_repository.go b/persistence/artist_repository.go
index 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.go
index 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 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
}
diff --git a/tests/mock_artist_repo.go b/tests/mock_artist_repo.go
index 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")
}