Warn on XML deserialization errors

This commit is contained in:
ConfusedPolarBear 2022-09-27 20:31:18 -05:00
parent e18adc84f1
commit c41e134a10

View File

@ -9,6 +9,7 @@ using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Plugins;
using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Serialization;
using Microsoft.Extensions.Logging;
namespace ConfusedPolarBear.Plugin.IntroSkipper; namespace ConfusedPolarBear.Plugin.IntroSkipper;
@ -20,6 +21,7 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
private readonly object _serializationLock = new object(); private readonly object _serializationLock = new object();
private IXmlSerializer _xmlSerializer; private IXmlSerializer _xmlSerializer;
private ILibraryManager _libraryManager; private ILibraryManager _libraryManager;
private ILogger<Plugin> _logger;
private string _introPath; private string _introPath;
/// <summary> /// <summary>
@ -29,15 +31,18 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
/// <param name="xmlSerializer">Instance of the <see cref="IXmlSerializer"/> interface.</param> /// <param name="xmlSerializer">Instance of the <see cref="IXmlSerializer"/> interface.</param>
/// <param name="serverConfiguration">Server configuration manager.</param> /// <param name="serverConfiguration">Server configuration manager.</param>
/// <param name="libraryManager">Library manager.</param> /// <param name="libraryManager">Library manager.</param>
/// <param name="logger">Logger.</param>
public Plugin( public Plugin(
IApplicationPaths applicationPaths, IApplicationPaths applicationPaths,
IXmlSerializer xmlSerializer, IXmlSerializer xmlSerializer,
IServerConfigurationManager serverConfiguration, IServerConfigurationManager serverConfiguration,
ILibraryManager libraryManager) ILibraryManager libraryManager,
ILogger<Plugin> logger)
: base(applicationPaths, xmlSerializer) : base(applicationPaths, xmlSerializer)
{ {
_xmlSerializer = xmlSerializer; _xmlSerializer = xmlSerializer;
_libraryManager = libraryManager; _libraryManager = libraryManager;
_logger = logger;
// Create the base & cache directories (if needed). // Create the base & cache directories (if needed).
FingerprintCachePath = Path.Join(applicationPaths.PluginConfigurationsPath, "intros", "cache"); FingerprintCachePath = Path.Join(applicationPaths.PluginConfigurationsPath, "intros", "cache");
@ -57,7 +62,14 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
ConfigurationChanged += OnConfigurationChanged; ConfigurationChanged += OnConfigurationChanged;
RestoreTimestamps(); try
{
RestoreTimestamps();
}
catch (Exception ex)
{
_logger.LogWarning("Unable to load introduction timestamps: {Exception}", ex);
}
} }
/// <summary> /// <summary>