check that old config is not null

This commit is contained in:
Kilian von Pflugk 2024-10-30 20:37:03 +01:00
parent 36825a898d
commit d9973ed90a

View File

@ -108,16 +108,18 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
using (var reader = XmlReader.Create(fileStream, settings))
{
var oldConfig = serializer.Deserialize(reader) as PluginConfiguration;
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);
}
}