From abb4cf44f4b9f2146f2f11c5b6a0c4092303f802 Mon Sep 17 00:00:00 2001 From: Kilian von Pflugk Date: Wed, 30 Oct 2024 20:37:03 +0100 Subject: [PATCH] check that old config is not null --- IntroSkipper/Plugin.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/IntroSkipper/Plugin.cs b/IntroSkipper/Plugin.cs index 35de422..8896da7 100644 --- a/IntroSkipper/Plugin.cs +++ b/IntroSkipper/Plugin.cs @@ -109,16 +109,18 @@ public class Plugin : BasePlugin, IHasWebPages using (var reader = XmlReader.Create(fileStream, settings)) { - var oldConfig = serializer.Deserialize(reader) as PluginConfiguration; - Instance.UpdateConfiguration(oldConfig); - File.Delete(oldConfigFile); + if (serializer.Deserialize(reader) is PluginConfiguration oldConfig) + { + Instance.UpdateConfiguration(oldConfig); + File.Delete(oldConfigFile); + } } } } catch (Exception ex) { // Handle exceptions, such as file not found, deserialization errors, etc. - _logger.LogWarning("Something stupid happend: {Exception}", ex); + _logger.LogWarning("Something stupid happened: {Exception}", ex); } }