From dfba9e9b4d8ec308acdad7e9ebc9e11eaf7f4f67 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 20 Jun 2020 16:16:37 -0400 Subject: [PATCH] Fixed: Update Credits during refresh instead inserting old record --- src/NzbDrone.Core/Movies/Credits/CreditService.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core/Movies/Credits/CreditService.cs b/src/NzbDrone.Core/Movies/Credits/CreditService.cs index 95644712a..da885b549 100644 --- a/src/NzbDrone.Core/Movies/Credits/CreditService.cs +++ b/src/NzbDrone.Core/Movies/Credits/CreditService.cs @@ -71,8 +71,10 @@ public List UpdateCredits(List 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);