Don't overwrite NFO images (#9452)

Co-authored-by: Cody Robibero <cody@robibe.ro>
This commit is contained in:
SenorSmartyPants 2023-03-18 20:24:48 -05:00 committed by GitHub
parent b2461feffb
commit 39677525f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 2 deletions

View File

@ -1,6 +1,7 @@
#pragma warning disable CA1819, CS1591
using System;
using System.Collections.Generic;
using System.Linq;
using MediaBrowser.Model.Entities;
@ -23,7 +24,7 @@ namespace MediaBrowser.Controller.Providers
public bool ReplaceAllImages { get; set; }
public ImageType[] ReplaceImages { get; set; }
public IReadOnlyList<ImageType> ReplaceImages { get; set; }
public bool IsAutomated { get; set; }

View File

@ -273,7 +273,7 @@ namespace MediaBrowser.Providers.Manager
}
if (!refreshOptions.ReplaceAllImages &&
refreshOptions.ReplaceImages.Length == 0 &&
refreshOptions.ReplaceImages.Count == 0 &&
ContainsImages(item, provider.GetSupportedImages(item).ToList(), savedOptions, backdropLimit))
{
return;

View File

@ -26,6 +26,8 @@ namespace MediaBrowser.Providers.Manager
where TItemType : BaseItem, IHasLookupInfo<TIdType>, new()
where TIdType : ItemLookupInfo, new()
{
private static readonly ImageType[] AllImageTypes = Enum.GetValues<ImageType>();
protected MetadataService(IServerConfigurationManager serverConfigurationManager, ILogger<MetadataService<TItemType, TIdType>> logger, IProviderManager providerManager, IFileSystem fileSystem, ILibraryManager libraryManager)
{
ServerConfigurationManager = serverConfigurationManager;
@ -672,6 +674,8 @@ namespace MediaBrowser.Providers.Manager
}
var hasLocalMetadata = false;
var replaceImages = AllImageTypes.ToList();
var localImagesFound = false;
foreach (var provider in providers.OfType<ILocalMetadataProvider<TItemType>>())
{
@ -698,6 +702,10 @@ namespace MediaBrowser.Providers.Manager
await ProviderManager.SaveImage(item, remoteImage.Url, remoteImage.Type, null, cancellationToken).ConfigureAwait(false);
refreshResult.UpdateType |= ItemUpdateType.ImageUpdate;
// remove imagetype that has just been downloaded
replaceImages.Remove(remoteImage.Type);
localImagesFound = true;
}
catch (HttpRequestException ex)
{
@ -705,6 +713,12 @@ namespace MediaBrowser.Providers.Manager
}
}
if (localImagesFound)
{
options.ReplaceAllImages = false;
options.ReplaceImages = replaceImages;
}
if (imageService.MergeImages(item, localItem.Images))
{
refreshResult.UpdateType |= ItemUpdateType.ImageUpdate;