Remove warnings

This commit is contained in:
Joe Rogers 2022-01-01 00:22:46 +01:00
parent 6e4710d048
commit b03f56c3d6
No known key found for this signature in database
GPG Key ID: 0074AD57B8FDBBB4
2 changed files with 33 additions and 23 deletions

View File

@ -45,7 +45,7 @@ namespace MediaBrowser.Providers.Manager
/// </summary>
public class ProviderManager : IProviderManager, IDisposable
{
private readonly object _refreshQueueLock = new ();
private readonly object _refreshQueueLock = new();
private readonly ILogger<ProviderManager> _logger;
private readonly IHttpClientFactory _httpClientFactory;
private readonly ILibraryMonitor _libraryMonitor;
@ -55,9 +55,9 @@ namespace MediaBrowser.Providers.Manager
private readonly ISubtitleManager _subtitleManager;
private readonly IServerConfigurationManager _configurationManager;
private readonly IBaseItemManager _baseItemManager;
private readonly ConcurrentDictionary<Guid, double> _activeRefreshes = new ();
private readonly CancellationTokenSource _disposeCancellationTokenSource = new ();
private readonly SimplePriorityQueue<Tuple<Guid, MetadataRefreshOptions>> _refreshQueue = new ();
private readonly ConcurrentDictionary<Guid, double> _activeRefreshes = new();
private readonly CancellationTokenSource _disposeCancellationTokenSource = new();
private readonly SimplePriorityQueue<Tuple<Guid, MetadataRefreshOptions>> _refreshQueue = new();
private IImageProvider[] _imageProviders = Array.Empty<IImageProvider>();
private IMetadataService[] _metadataServices = Array.Empty<IMetadataService>();
@ -164,6 +164,10 @@ namespace MediaBrowser.Providers.Manager
{
contentType = "image/png";
}
else
{
throw new HttpRequestException("Invalid image received: contentType not set.", null, response.StatusCode);
}
}
// thetvdb will sometimes serve a rubbish 404 html page with a 200 OK code, because reasons...
@ -589,7 +593,7 @@ namespace MediaBrowser.Providers.Manager
foreach (var saver in savers.Where(i => IsSaverEnabledForItem(i, item, libraryOptions, updateType, false)))
{
_logger.LogDebug("Saving {0} to {1}.", item.Path ?? item.Name, saver.Name);
_logger.LogDebug("Saving {Item} to {Saver}", item.Path ?? item.Name, saver.Name);
if (saver is IMetadataFileSaver fileSaver)
{
@ -601,7 +605,7 @@ namespace MediaBrowser.Providers.Manager
}
catch (Exception ex)
{
_logger.LogError(ex, "Error in {0} GetSavePath", saver.Name);
_logger.LogError(ex, "Error in {Saver} GetSavePath", saver.Name);
continue;
}
@ -688,7 +692,7 @@ namespace MediaBrowser.Providers.Manager
}
catch (Exception ex)
{
_logger.LogError(ex, "Error in {0}.IsEnabledFor", saver.Name);
_logger.LogError(ex, "Error in {Saver}.IsEnabledFor", saver.Name);
return false;
}
}
@ -838,7 +842,7 @@ namespace MediaBrowser.Providers.Manager
}
catch (Exception ex)
{
_logger.LogError(ex, "Error in {0}.Supports", i.GetType().Name);
_logger.LogError(ex, "Error in {Type}.Supports", i.GetType().Name);
return false;
}
});
@ -904,7 +908,7 @@ namespace MediaBrowser.Providers.Manager
/// <inheritdoc/>
public void OnRefreshStart(BaseItem item)
{
_logger.LogDebug("OnRefreshStart {0}", item.Id.ToString("N", CultureInfo.InvariantCulture));
_logger.LogDebug("OnRefreshStart {Item}", item.Id.ToString("N", CultureInfo.InvariantCulture));
_activeRefreshes[item.Id] = 0;
RefreshStarted?.Invoke(this, new GenericEventArgs<BaseItem>(item));
}
@ -912,7 +916,7 @@ namespace MediaBrowser.Providers.Manager
/// <inheritdoc/>
public void OnRefreshComplete(BaseItem item)
{
_logger.LogDebug("OnRefreshComplete {0}", item.Id.ToString("N", CultureInfo.InvariantCulture));
_logger.LogDebug("OnRefreshComplete {Item}", item.Id.ToString("N", CultureInfo.InvariantCulture));
_activeRefreshes.Remove(item.Id, out _);
@ -934,7 +938,7 @@ namespace MediaBrowser.Providers.Manager
public void OnRefreshProgress(BaseItem item, double progress)
{
var id = item.Id;
_logger.LogDebug("OnRefreshProgress {0} {1}", id.ToString("N", CultureInfo.InvariantCulture), progress);
_logger.LogDebug("OnRefreshProgress {Id} {Progress}", id.ToString("N", CultureInfo.InvariantCulture), progress);
// TODO: Need to hunt down the conditions for this happening
_activeRefreshes.AddOrUpdate(

View File

@ -1,21 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Controller;
using MediaBrowser.Controller.BaseItemManager;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Subtitles;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.IO;
using MediaBrowser.Providers.Manager;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Moq;
using Xunit;
// Allow Moq to see internal class
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
namespace Jellyfin.Providers.Tests.Manager
{
public class ProviderManagerTests
@ -23,7 +31,7 @@ namespace Jellyfin.Providers.Tests.Manager
private static readonly ILogger<ProviderManager> _logger = new NullLogger<ProviderManager>();
private static TheoryData<Mock<IMetadataService>[], int> RefreshSingleItemOrderData()
=> new ()
=> new()
{
// no order set, uses provided order
{
@ -110,7 +118,7 @@ namespace Jellyfin.Providers.Tests.Manager
}
private static TheoryData<int, int[]?, int[]?, int?[]?, int[]> GetImageProvidersOrderData()
=> new ()
=> new()
{
{ 3, null, null, null, new[] { 0, 1, 2 } }, // no order options set
@ -238,7 +246,7 @@ namespace Jellyfin.Providers.Tests.Manager
{
var l = nameof(ILocalMetadataProvider);
var r = nameof(IRemoteMetadataProvider);
return new ()
return new()
{
{ new[] { l, l, r, r }, null, null, null, null, null, new[] { 0, 1, 2, 3 } }, // no order options set
@ -269,8 +277,6 @@ namespace Jellyfin.Providers.Tests.Manager
// IHasOrder ordering (not interleaved, doesn't care about types)
{ new[] { l, l, r, r }, null, null, null, null, new int?[] { 2, null, 1, null }, new[] { 2, 0, 1, 3 } }, // partially defined
{ new[] { l, l, r, r }, null, null, null, null, new int?[] { 3, 2, 1, 0 }, new[] { 3, 2, 1, 0 } }, // full reverse order
// note odd interaction - orderby determines order of slot when local and remote both have a slot 0
{ new[] { l, l, r, r }, new[] { 1 }, new[] { 3 }, null, null, new int?[] { null, 2, null, 1 }, new[] { 3, 1, 0, 2 } }, // sorts interleaved results
// multiple orders set
{ new[] { l, l, l, r, r, r }, new[] { 1 }, new[] { 4 }, new[] { 2, 1, 0 }, new[] { 5, 4, 3 }, null, new[] { 1, 4, 0, 2, 3, 5 } }, // partial library order first, server order ignored
@ -562,13 +568,13 @@ namespace Jellyfin.Providers.Tests.Manager
.Returns(libraryOptions ?? new LibraryOptions());
var providerManager = new ProviderManager(
null,
null,
Mock.Of<IHttpClientFactory>(),
Mock.Of<ISubtitleManager>(),
serverConfigurationManager.Object,
null,
Mock.Of<ILibraryMonitor>(),
_logger,
null,
null,
Mock.Of<IFileSystem>(),
Mock.Of<IServerApplicationPaths>(),
libraryManager.Object,
baseItemManager!);
@ -595,7 +601,7 @@ namespace Jellyfin.Providers.Tests.Manager
/// <summary>
/// Simple <see cref="BaseItem"/> extension to make SupportsLocalMetadata directly settable.
/// </summary>
public class MetadataTestItem : BaseItem, IHasLookupInfo<MetadataTestItemInfo>
internal class MetadataTestItem : BaseItem, IHasLookupInfo<MetadataTestItemInfo>
{
public bool EnableLocalMetadata { get; set; } = true;
@ -607,7 +613,7 @@ namespace Jellyfin.Providers.Tests.Manager
}
}
public class MetadataTestItemInfo : ItemLookupInfo
internal class MetadataTestItemInfo : ItemLookupInfo
{
}
}