Don't save config until rule value is checked to be valid
Found by #2111
This commit is contained in:
1 parent
02ede92f76
commit
9f8e6f5168
1 file changed
+4
-4
@@ -695,16 +695,16 @@ public class SettingsManager {
|
|||||||
{
|
{
|
||||||
if (locked()) return 0;
|
if (locked()) return 0;
|
||||||
if (!rules.containsKey(rule.name())) return 0;
|
if (!rules.containsKey(rule.name())) return 0;
|
||||||
ConfigReadResult conf = readSettingsFromConf(getFile());
|
|
||||||
conf.ruleMap().put(rule.name(), stringValue);
|
|
||||||
writeSettingsToConf(conf); // this may feels weird, but if conf
|
|
||||||
// is locked, it will never reach this point.
|
|
||||||
try {
|
try {
|
||||||
rule.set(source, stringValue);
|
rule.set(source, stringValue);
|
||||||
Messenger.m(source ,"gi "+String.format(tr(TranslationKeys.DEFAULT_SET), RuleHelper.translatedName(rule), stringValue));
|
Messenger.m(source ,"gi "+String.format(tr(TranslationKeys.DEFAULT_SET), RuleHelper.translatedName(rule), stringValue));
|
||||||
} catch (InvalidRuleValueException e) {
|
} catch (InvalidRuleValueException e) {
|
||||||
e.notifySource(rule.name(), source);
|
e.notifySource(rule.name(), source);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
ConfigReadResult conf = readSettingsFromConf(getFile());
|
||||||
|
conf.ruleMap().put(rule.name(), stringValue);
|
||||||
|
writeSettingsToConf(conf);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
// removes overrides of the default values in the file
|
// removes overrides of the default values in the file
|
||||||
|
|||||||
Reference in new issue
Block a user