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:
John Reese 2011-09-29 09:54:44 -04:00
parent a69ec09d6b
commit 1f76601c56
1 changed files with 20 additions and 0 deletions

View File

@ -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
{ {