diff options
author | Jan Lehnardt <jan@apache.org> | 2009-01-05 10:38:39 +0000 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2009-01-05 10:38:39 +0000 |
commit | 48ad84d64167a97d766904d306376b6b95a4f28f (patch) | |
tree | a4aa120c66fefa316c2052edff726e30c44fa21f /src/couchdb | |
parent | 10eac24f530b5de1ea30c83518d3971f99890db6 (diff) |
Fix ini-section duplication. When we tried to assign a value to a config-item that happened to be set to that value already, a new and duplicated ini section with that config parameter was written to the ini file.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@731521 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb')
-rw-r--r-- | src/couchdb/couch_config_writer.erl | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/couchdb/couch_config_writer.erl b/src/couchdb/couch_config_writer.erl index 270e615f..fd4a0215 100644 --- a/src/couchdb/couch_config_writer.erl +++ b/src/couchdb/couch_config_writer.erl @@ -42,11 +42,15 @@ save_to_file({{Section, Option}, Value}, File) -> % produce the contents for the config file NewFileContents = - case NewFileContents2 = save_loop({{SectionName, OptionList}, Value}, Lines, "", "", []) of + case {NewFileContents2, DoneOptions} = save_loop({{SectionName, OptionList}, Value}, Lines, "", "", []) of % we didn't change anything, that means we couldn't find a matching % [ini section] in which case we just append a new one. - OldFileContents -> - append_new_ini_section({{SectionName, OptionList}, Value}, OldFileContents); + {OldFileContents, DoneOptions} -> + % but only if we haven't actually written anything. + case lists:member(OptionList, DoneOptions) of + true -> OldFileContents; + _ -> append_new_ini_section({{SectionName, OptionList}, Value}, OldFileContents) + end; _ -> NewFileContents2 end, @@ -110,9 +114,9 @@ save_loop({{Section, Option}, Value}, [], OldSection, NewFileContents, DoneOptio case lists:member(Option, DoneOptions) of % append Deferred Option false when Section == OldSection -> - NewFileContents ++ "\n" ++ Option ++ " = " ++ Value ++ "\n"; + {NewFileContents ++ "\n" ++ Option ++ " = " ++ Value ++ "\n", DoneOptions}; % we're out of new lines, just return the new file's contents - _ -> NewFileContents + _ -> {NewFileContents, DoneOptions} end. append_new_ini_section({{SectionName, Option}, Value}, OldFileContents) -> |