From d9973ed90a38c65963b447142ff3fb479d2a51f3 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 8d61435..7cd4656 100644 --- a/IntroSkipper/Plugin.cs +++ b/IntroSkipper/Plugin.cs @@ -108,16 +108,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); } }