Remove IHttpClient from ItemImageProvider

This commit is contained in:
crobibero 2020-08-17 11:54:55 -06:00
parent 7a0fa34162
commit 10ac32569e

View File

@ -465,9 +465,15 @@ namespace MediaBrowser.Providers.Manager
try
{
var response = await provider.GetImageResponse(url, cancellationToken).ConfigureAwait(false);
using var response = await provider.GetImageResponse(url, cancellationToken).ConfigureAwait(false);
await _providerManager.SaveImage(item, response.Content, response.ContentType, type, null, cancellationToken).ConfigureAwait(false);
await _providerManager.SaveImage(
item,
await response.Content.ReadAsStreamAsync().ConfigureAwait(false),
response.Content.Headers.ContentType.MediaType,
type,
null,
cancellationToken).ConfigureAwait(false);
result.UpdateType = result.UpdateType | ItemUpdateType.ImageUpdate;
return true;
@ -565,14 +571,14 @@ namespace MediaBrowser.Providers.Manager
try
{
var response = await provider.GetImageResponse(url, cancellationToken).ConfigureAwait(false);
using var response = await provider.GetImageResponse(url, cancellationToken).ConfigureAwait(false);
// If there's already an image of the same size, skip it
if (response.ContentLength.HasValue)
if (response.Content.Headers.ContentLength.HasValue)
{
try
{
if (item.GetImages(imageType).Any(i => _fileSystem.GetFileInfo(i.Path).Length == response.ContentLength.Value))
if (item.GetImages(imageType).Any(i => _fileSystem.GetFileInfo(i.Path).Length == response.Content.Headers.ContentLength.Value))
{
response.Content.Dispose();
continue;
@ -584,7 +590,13 @@ namespace MediaBrowser.Providers.Manager
}
}
await _providerManager.SaveImage(item, response.Content, response.ContentType, imageType, null, cancellationToken).ConfigureAwait(false);
await _providerManager.SaveImage(
item,
await response.Content.ReadAsStreamAsync().ConfigureAwait(false),
response.Content.Headers.ContentType.MediaType,
imageType,
null,
cancellationToken).ConfigureAwait(false);
result.UpdateType = result.UpdateType | ItemUpdateType.ImageUpdate;
}
catch (HttpException ex)