mirror of
https://github.com/Lidarr/Lidarr
synced 2025-12-06 08:25:54 +01:00
Fixed: List Import no longer fails due to duplicates
Closes Sonarr/Sonarr#4100 (cherry picked from commit 19ff7bdc3050a83a7e30140e2c2c89c4dfba5f84)
This commit is contained in:
parent
38e11ee768
commit
7cfa16a10b
1 changed files with 6 additions and 0 deletions
|
|
@ -67,6 +67,7 @@ public List<Artist> AddArtists(List<Artist> newArtists, bool doRefresh = true, b
|
||||||
{
|
{
|
||||||
var added = DateTime.UtcNow;
|
var added = DateTime.UtcNow;
|
||||||
var artistsToAdd = new List<Artist>();
|
var artistsToAdd = new List<Artist>();
|
||||||
|
var existingArtists = _artistService.GetAllArtists();
|
||||||
|
|
||||||
foreach (var s in newArtists)
|
foreach (var s in newArtists)
|
||||||
{
|
{
|
||||||
|
|
@ -84,6 +85,11 @@ public List<Artist> AddArtists(List<Artist> newArtists, bool doRefresh = true, b
|
||||||
var artist = AddSkyhookData(s);
|
var artist = AddSkyhookData(s);
|
||||||
artist = SetPropertiesAndValidate(artist);
|
artist = SetPropertiesAndValidate(artist);
|
||||||
artist.Added = added;
|
artist.Added = added;
|
||||||
|
if (existingArtists.Any(f => f.ForeignArtistId == artist.ForeignArtistId))
|
||||||
|
{
|
||||||
|
_logger.Debug("Musicbrainz ID {0} was not added due to validation failure: Artist already exists in database", s.ForeignArtistId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (artistsToAdd.Any(f => f.ForeignArtistId == artist.ForeignArtistId))
|
if (artistsToAdd.Any(f => f.ForeignArtistId == artist.ForeignArtistId))
|
||||||
{
|
{
|
||||||
_logger.Debug("Musicbrainz ID {0} was not added due to validation failure: Artist already exists on list", s.ForeignArtistId);
|
_logger.Debug("Musicbrainz ID {0} was not added due to validation failure: Artist already exists on list", s.ForeignArtistId);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue