check that old config is not null

This commit is contained in:
Kilian von Pflugk 2024-10-30 20:37:03 +01:00
parent 27c4843904
commit abb4cf44f4

View File

@ -109,16 +109,18 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
using (var reader = XmlReader.Create(fileStream, settings)) 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); Instance.UpdateConfiguration(oldConfig);
File.Delete(oldConfigFile);
}
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
// Handle exceptions, such as file not found, deserialization errors, etc. // Handle exceptions, such as file not found, deserialization errors, etc.
_logger.LogWarning("Something stupid happend: {Exception}", ex); _logger.LogWarning("Something stupid happened: {Exception}", ex);
} }
} }