mirror of https://github.com/SeanOMik/znc-push.git
Get missing defaults and save options when loading
Follow-up to ref 60632d42f
. Initial implementation would lose loaded
options when the module was reloaded, and would cause errors if the
loaded dictionary did not contain all of the option values.
This commit is contained in:
parent
a69ec09d6b
commit
1f76601c56
20
push.cpp
20
push.cpp
|
@ -963,6 +963,26 @@ class CPushMod : public CModule
|
||||||
if (status == MCString::MCS_SUCCESS)
|
if (status == MCString::MCS_SUCCESS)
|
||||||
{
|
{
|
||||||
PutModule("Options loaded from " + file_path);
|
PutModule("Options loaded from " + file_path);
|
||||||
|
|
||||||
|
// Restore any defaults that aren't in the loaded dictionary,
|
||||||
|
// and save loaded options to ZNC's data store
|
||||||
|
for (MCString::iterator i = defaults.begin(); i != defaults.end(); i++)
|
||||||
|
{
|
||||||
|
CString option = i->first;
|
||||||
|
MCString::iterator pos = options.find(option);
|
||||||
|
|
||||||
|
if (pos == options.end())
|
||||||
|
{
|
||||||
|
options[option] = defaults[option];
|
||||||
|
DelNV(option);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetNV(option, options[option]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
authencode();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue