diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index a7238831bd..667574f396 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -1071,10 +1071,14 @@ namespace MediaBrowser.Providers.Manager var key = id.Key; // Don't replace existing Id's. - if (replaceData || !target.ProviderIds.ContainsKey(key)) + if (replaceData) { target.ProviderIds[key] = id.Value; } + else + { + target.ProviderIds.TryAdd(key, id.Value); + } } MergeAlbumArtist(source, target, replaceData); @@ -1120,10 +1124,7 @@ namespace MediaBrowser.Providers.Manager { foreach (var providerId in personInSource.ProviderIds) { - if (!person.ProviderIds.ContainsKey(providerId.Key)) - { - person.ProviderIds[providerId.Key] = providerId.Value; - } + person.ProviderIds.TryAdd(providerId.Key, providerId.Value); } if (string.IsNullOrWhiteSpace(person.ImageUrl)) diff --git a/tests/Jellyfin.Providers.Tests/Manager/ItemImageProviderTests.cs b/tests/Jellyfin.Providers.Tests/Manager/ItemImageProviderTests.cs index f466f5fbc8..c0931dbcf1 100644 --- a/tests/Jellyfin.Providers.Tests/Manager/ItemImageProviderTests.cs +++ b/tests/Jellyfin.Providers.Tests/Manager/ItemImageProviderTests.cs @@ -157,8 +157,9 @@ namespace Jellyfin.Providers.Tests.Manager { Assert.True(changed); // before and after paths are the same, verify updated by size reset to 0 - Assert.Equal(imageCount, item.GetImages(imageType).Count()); - foreach (var image in item.GetImages(imageType)) + var typedImages = item.GetImages(imageType).ToArray(); + Assert.Equal(imageCount, typedImages.Length); + foreach (var image in typedImages) { Assert.Equal(updatedTime, image.DateModified); Assert.Equal(0, image.Height);