From 991ac1c20f99187bc67058f2d427c25aa345479c Mon Sep 17 00:00:00 2001 From: Mikal Stordal Date: Fri, 25 Oct 2024 10:37:38 +0200 Subject: [PATCH] fix: ensure only 1 xref per company exist Closes #1191 --- Shoko.Server/Providers/TMDB/TmdbMetadataService.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Shoko.Server/Providers/TMDB/TmdbMetadataService.cs b/Shoko.Server/Providers/TMDB/TmdbMetadataService.cs index 34d45d6d6..c1223e89f 100644 --- a/Shoko.Server/Providers/TMDB/TmdbMetadataService.cs +++ b/Shoko.Server/Providers/TMDB/TmdbMetadataService.cs @@ -1931,7 +1931,8 @@ private void PurgeTitlesAndOverviews(ForeignEntityType foreignType, int foreignI private async Task UpdateCompanies(IEntityMetadata tmdbEntity, List companies) { var existingXrefs = _xrefTmdbCompanyEntity.GetByTmdbEntityTypeAndID(tmdbEntity.Type, tmdbEntity.Id) - .ToDictionary(xref => xref.TmdbCompanyID); + .GroupBy(xref => xref.TmdbCompanyID) + .ToDictionary(xref => xref.Key, groupBy => groupBy.ToList()); var xrefsToAdd = 0; var xrefsToSkip = new HashSet(); var xrefsToSave = new List(); @@ -1939,8 +1940,9 @@ private async Task UpdateCompanies(IEntityMetadata tmdbEntity, List UpdateCompanies(IEntityMetadata tmdbEntity, List xrefs) .ExceptBy(xrefsToSkip, o => o.TMDB_Company_EntityID) .ToList();