Fix problem with merging values from multiple config files

This commit is contained in:
Paweł Chmielowski 2015-07-24 15:45:29 +02:00
parent e211bf7131
commit 76104cd117
1 changed files with 6 additions and 5 deletions

View File

@ -385,18 +385,19 @@ include_config_files(Terms) ->
include_config_file(File, Opts)
end, lists:flatten(FileOpts)),
SpecialTerms = dict:from_list([{hosts, none}, {listen, none}, {modules, none}]),
SpecialTerms = dict:from_list([{hosts, []}, {listen, []}, {modules, []}]),
PartDict = dict:store(rest, [], SpecialTerms),
Partition = fun(L) ->
lists:foldr(fun({Name, Val} = Pair, Dict) ->
case dict:find(Name, SpecialTerms) of
{ok, _} ->
dict:store(Name, Val, Dict);
dict:append_list(Name, Val, Dict);
_ ->
dict:update(rest, fun(L1) -> [Pair|L1] end, Dict)
dict:append(rest, Pair, Dict)
end;
(Tuple, Dict2) ->
dict:update(rest, fun(L2) -> [Tuple|L2] end, Dict2)
end, dict:from_list([{rest, []}]), L)
dict:append(rest, Tuple, Dict2)
end, PartDict, L)
end,
Merged = dict:merge(fun(_Name, V1, V2) -> V1 ++ V2 end,