preserve settings that are loaded from disk, even if they match the defaults
Costa Tsaousis (ktsaou) committed
Oct 23, 2017 at 22:16 UTC
8af62dce5711e7c8e3e9050fdd31d271e834545a
1 file changed
+4
-2
src/appconfig.c
+4
-2
@@ -567,6 +567,7 @@ void appconfig_generate(struct config *root, BUFFER *wb, int only_changed)
567
else pri = 2;
568
569
if(i == pri) {
570
+ int loaded = 0;
571
int used = 0;
572
int changed = 0;
573
int count = 0;
@@ -574,13 +575,14 @@ void appconfig_generate(struct config *root, BUFFER *wb, int only_changed)
575
config_section_wrlock(co);
576
for(cv = co->values; cv ; cv = cv->next) {
577
used += (cv->flags & CONFIG_VALUE_USED)?1:0;
578
+ loaded += (cv->flags & CONFIG_VALUE_LOADED)?1:0;
579
changed += (cv->flags & CONFIG_VALUE_CHANGED)?1:0;
580
count++;
581
}
582
config_section_unlock(co);
583
584
if(!count) continue;
583
- if(only_changed && !changed) continue;
585
+ if(only_changed && !changed && !loaded) continue;
586
587
if(!used) {
588
buffer_sprintf(wb, "\n# section '%s' is not used.", co->name);
@@ -594,7 +596,7 @@ void appconfig_generate(struct config *root, BUFFER *wb, int only_changed)
596
if(used && !(cv->flags & CONFIG_VALUE_USED)) {
597
buffer_sprintf(wb, "\n\t# option '%s' is not used.\n", cv->name);
598
}
597
- buffer_sprintf(wb, "\t%s%s = %s\n", ((!(cv->flags & CONFIG_VALUE_CHANGED)) && (cv->flags & CONFIG_VALUE_USED))?"# ":"", cv->name, cv->value);
599
+ buffer_sprintf(wb, "\t%s%s = %s\n", ((!(cv->flags & CONFIG_VALUE_LOADED)) && (!(cv->flags & CONFIG_VALUE_CHANGED)) && (cv->flags & CONFIG_VALUE_USED))?"# ":"", cv->name, cv->value);
600
}
601
config_section_unlock(co);
602
}