1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Fixed: Update Credits during refresh instead inserting old record

This commit is contained in:
Qstick 2020-06-20 16:16:37 -04:00
parent 28e6e4ed7b
commit dfba9e9b4d

View File

@ -71,8 +71,10 @@ public List<Credit> UpdateCredits(List<Credit> credits, Movie movie)
// Should never have multiple credits with same credit_id, but check to ensure incase TMDB is on fritz
var dupeFreeCredits = credits.DistinctBy(m => m.CreditTmdbId).ToList();
var insert = dupeFreeCredits.Where(t => !existingCredits.Any(c => c.CreditTmdbId == t.CreditTmdbId)).ToList();
var update = existingCredits.Where(t => dupeFreeCredits.Any(c => c.CreditTmdbId == t.CreditTmdbId)).ToList();
dupeFreeCredits.ForEach(c => c.Id = existingCredits.FirstOrDefault(t => t.CreditTmdbId == c.CreditTmdbId)?.Id ?? 0);
var insert = dupeFreeCredits.Where(t => t.Id == 0).ToList();
var update = dupeFreeCredits.Where(t => t.Id > 0).ToList();
var delete = existingCredits.Where(t => !dupeFreeCredits.Any(c => c.CreditTmdbId == t.CreditTmdbId)).ToList();
_creditRepo.DeleteMany(delete);