check that old config is not null
This commit is contained in:
parent
36825a898d
commit
d9973ed90a
@ -108,16 +108,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user