24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-06-02 21:17:12 +02:00

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

View File

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