Clarify naming, minor method ordering improvement

pull/7039/head
Joe Rogers 3 years ago
parent 56900d0fc3
commit 11c7c24f0e
No known key found for this signature in database
GPG Key ID: 0074AD57B8FDBBB4

@ -297,18 +297,31 @@ namespace MediaBrowser.Providers.Manager
return GetRemoteImageProviders(item, true).Select(i => new ImageProviderInfo(i.Name, i.GetSupportedImages(item).ToArray()));
}
private IEnumerable<IRemoteImageProvider> GetRemoteImageProviders(BaseItem item, bool includeDisabled)
{
var options = GetMetadataOptions(item);
var libraryOptions = _libraryManager.GetLibraryOptions(item);
return GetImageProvidersInternal(
item,
libraryOptions,
options,
new ImageRefreshOptions(new DirectoryService(_fileSystem)),
includeDisabled).OfType<IRemoteImageProvider>();
}
/// <inheritdoc/>
public IEnumerable<IImageProvider> GetImageProviders(BaseItem item, ImageRefreshOptions refreshOptions)
{
return GetImageProviders(item, _libraryManager.GetLibraryOptions(item), GetMetadataOptions(item), refreshOptions, false);
return GetImageProvidersInternal(item, _libraryManager.GetLibraryOptions(item), GetMetadataOptions(item), refreshOptions, false);
}
private IEnumerable<IImageProvider> GetImageProviders(BaseItem item, LibraryOptions libraryOptions, MetadataOptions options, ImageRefreshOptions refreshOptions, bool includeDisabled)
private IEnumerable<IImageProvider> GetImageProvidersInternal(BaseItem item, LibraryOptions libraryOptions, MetadataOptions options, ImageRefreshOptions refreshOptions, bool includeDisabled)
{
var typeOptions = libraryOptions.GetTypeOptions(item.GetType().Name);
var fetcherOrder = typeOptions?.ImageFetcherOrder ?? options.ImageFetcherOrder;
return _imageProviders.Where(i => CanRefresh(i, item, libraryOptions, refreshOptions, includeDisabled))
return _imageProviders.Where(i => CanRefreshImages(i, item, libraryOptions, refreshOptions, includeDisabled))
.OrderBy(i => GetConfiguredOrder(fetcherOrder, i.Name))
.ThenBy(GetOrder);
}
@ -342,25 +355,12 @@ namespace MediaBrowser.Providers.Manager
var currentOptions = globalMetadataOptions;
return _metadataProviders.OfType<IMetadataProvider<T>>()
.Where(i => CanRefresh(i, item, libraryOptions, includeDisabled, forceEnableInternetMetadata))
.Where(i => CanRefreshMetadata(i, item, libraryOptions, includeDisabled, forceEnableInternetMetadata))
.OrderBy(i => GetConfiguredOrder(item, i, libraryOptions, currentOptions))
.ThenBy(GetDefaultOrder);
}
private IEnumerable<IRemoteImageProvider> GetRemoteImageProviders(BaseItem item, bool includeDisabled)
{
var options = GetMetadataOptions(item);
var libraryOptions = _libraryManager.GetLibraryOptions(item);
return GetImageProviders(
item,
libraryOptions,
options,
new ImageRefreshOptions(new DirectoryService(_fileSystem)),
includeDisabled).OfType<IRemoteImageProvider>();
}
private bool CanRefresh(
private bool CanRefreshMetadata(
IMetadataProvider provider,
BaseItem item,
LibraryOptions libraryOptions,
@ -401,7 +401,7 @@ namespace MediaBrowser.Providers.Manager
return true;
}
private bool CanRefresh(
private bool CanRefreshImages(
IImageProvider provider,
BaseItem item,
LibraryOptions libraryOptions,
@ -535,7 +535,7 @@ namespace MediaBrowser.Providers.Manager
var libraryOptions = new LibraryOptions();
var imageProviders = GetImageProviders(
var imageProviders = GetImageProvidersInternal(
dummy,
libraryOptions,
options,

@ -100,9 +100,9 @@ namespace Jellyfin.Providers.Tests.Manager
[InlineData(true, false, true)]
[InlineData(false, false, false)]
[InlineData(true, true, false)]
public void GetImageProviders_CanRefreshBasic_WhenSupportsWithoutError(bool supports, bool errorOnSupported, bool expected)
public void GetImageProviders_CanRefreshImagesBasic_WhenSupportsWithoutError(bool supports, bool errorOnSupported, bool expected)
{
GetImageProviders_CanRefresh_Tester(typeof(IImageProvider), supports, expected, errorOnSupported: errorOnSupported);
GetImageProviders_CanRefreshImages_Tester(typeof(IImageProvider), supports, expected, errorOnSupported: errorOnSupported);
}
[Theory]
@ -110,9 +110,9 @@ namespace Jellyfin.Providers.Tests.Manager
[InlineData(typeof(ILocalImageProvider), true, true)]
[InlineData(typeof(IImageProvider), false, false)]
[InlineData(typeof(IImageProvider), true, true)]
public void GetImageProviders_CanRefreshLocked_WhenLocalOrFullRefresh(Type providerType, bool fullRefresh, bool expected)
public void GetImageProviders_CanRefreshImagesLocked_WhenLocalOrFullRefresh(Type providerType, bool fullRefresh, bool expected)
{
GetImageProviders_CanRefresh_Tester(providerType, true, expected, itemLocked: true, fullRefresh: fullRefresh);
GetImageProviders_CanRefreshImages_Tester(providerType, true, expected, itemLocked: true, fullRefresh: fullRefresh);
}
[Theory]
@ -121,12 +121,12 @@ namespace Jellyfin.Providers.Tests.Manager
[InlineData(typeof(IDynamicImageProvider), true, true)]
[InlineData(typeof(IRemoteImageProvider), false, false)]
[InlineData(typeof(IDynamicImageProvider), false, false)]
public void GetImageProviders_CanRefreshEnabled_WhenLocalOrEnabled(Type providerType, bool enabled, bool expected)
public void GetImageProviders_CanRefreshImagesEnabled_WhenLocalOrEnabled(Type providerType, bool enabled, bool expected)
{
GetImageProviders_CanRefresh_Tester(providerType, true, expected, baseItemEnabled: enabled);
GetImageProviders_CanRefreshImages_Tester(providerType, true, expected, baseItemEnabled: enabled);
}
private static void GetImageProviders_CanRefresh_Tester(Type providerType, bool supports, bool expected, bool errorOnSupported = false, bool itemLocked = false, bool fullRefresh = false, bool baseItemEnabled = true)
private static void GetImageProviders_CanRefreshImages_Tester(Type providerType, bool supports, bool expected, bool errorOnSupported = false, bool itemLocked = false, bool fullRefresh = false, bool baseItemEnabled = true)
{
var item = new Movie
{

Loading…
Cancel
Save