aisamanra/config-ini

Bidir: setting in optional section with non-default value does not get written

Opened this issue · 3 comments

Steps to reproduce:

  • Use sectionOpt to specify an optional section foo
  • Add to foo a setting bar with a default value
  • Have the Bidir API read a config file that does not provide any foo section at all
  • Change the underlying data structure's value for foo to some value other than the default
  • Have the Bidir API write a new config file in the same location as the old one

Expected behavior: the new file now has a foo section with a bar setting indicating the new value.

Observed behavior: the new file still has no foo section and defaults bar to the default value.

The problem is that updateIniSections never checks for optional sections whose fields have been modified from their default values. It simply walks through the sections that already exist in the config file, updates them, and calls it good.

Patch incoming...

@aisamanra It turns out we'll need to prepare some other patches first. We thought this might be the only significant patch we need to get you, but there are other changes we've been sitting on that we haven't submitted.