From c41e134a102e836e485d37504e0b4c4723da1f0d Mon Sep 17 00:00:00 2001 From: ConfusedPolarBear <33811686+ConfusedPolarBear@users.noreply.github.com> Date: Tue, 27 Sep 2022 20:31:18 -0500 Subject: [PATCH] Warn on XML deserialization errors --- ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs index eb96689..97f041a 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs @@ -9,6 +9,7 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Serialization; +using Microsoft.Extensions.Logging; namespace ConfusedPolarBear.Plugin.IntroSkipper; @@ -20,6 +21,7 @@ public class Plugin : BasePlugin, IHasWebPages private readonly object _serializationLock = new object(); private IXmlSerializer _xmlSerializer; private ILibraryManager _libraryManager; + private ILogger _logger; private string _introPath; /// @@ -29,15 +31,18 @@ public class Plugin : BasePlugin, IHasWebPages /// Instance of the interface. /// Server configuration manager. /// Library manager. + /// Logger. public Plugin( IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer, IServerConfigurationManager serverConfiguration, - ILibraryManager libraryManager) + ILibraryManager libraryManager, + ILogger logger) : base(applicationPaths, xmlSerializer) { _xmlSerializer = xmlSerializer; _libraryManager = libraryManager; + _logger = logger; // Create the base & cache directories (if needed). FingerprintCachePath = Path.Join(applicationPaths.PluginConfigurationsPath, "intros", "cache"); @@ -57,7 +62,14 @@ public class Plugin : BasePlugin, IHasWebPages ConfigurationChanged += OnConfigurationChanged; - RestoreTimestamps(); + try + { + RestoreTimestamps(); + } + catch (Exception ex) + { + _logger.LogWarning("Unable to load introduction timestamps: {Exception}", ex); + } } ///