jaydoane commented on code in PR #4813:
URL: https://github.com/apache/couchdb/pull/4813#discussion_r1421497935
##########
src/config/src/config.erl:
##########
@@ -340,54 +331,30 @@ handle_call({delete, Sec, Key, Persist, Reason}, _From,
Config) ->
{reply, Else, Config}
end;
handle_call(reload, _From, Config) ->
- DiskKVs = lists:foldl(
- fun(IniFile, DiskKVs0) ->
- {ok, ParsedIniValues} = parse_ini_file(IniFile),
- lists:foldl(
- fun({K, V}, DiskKVs1) ->
- dict:store(K, V, DiskKVs1)
- end,
- DiskKVs0,
- ParsedIniValues
- )
- end,
- dict:new(),
- Config#config.ini_files
- ),
- % Update ets with anything we just read
- % from disk
- dict:fold(
- fun({Sec, Key} = K, V, _) ->
+ % Update ets with ini values.
+ IniMap = ini_map(Config#config.ini_files),
+ maps:foreach(
+ fun({Sec, Key} = K, V) ->
VExisting = get(Sec, Key, V),
- ets:insert(?MODULE, {K, V}),
+ true = ets:insert(?MODULE, {K, V}),
case V =:= VExisting of
true ->
ok;
false ->
- case is_sensitive(Sec, Key) of
- false ->
- couch_log:notice(
- "Reload detected config change ~s.~s = ~p",
- [Sec, Key, V]
- );
- true ->
- couch_log:notice(
- "Reload detected config change ~s.~s = '****'",
- [Sec, Key]
- )
- end,
+ couch_log:notice(
+ "Reload detected config change ~s.~s = ~p",
+ [Sec, Key, maybe_conceal(V, is_sensitive(Sec, Key))]
+ ),
Event = {config_change, Sec, Key, V, true},
gen_event:sync_notify(config_event, Event)
end
end,
- nil,
- DiskKVs
+ IniMap
),
- % And remove anything in ets that wasn't
- % on disk.
+ % And remove anything in ets that wasn't on disk.
ets:foldl(
fun({{Sec, Key} = K, _}, _) ->
- case dict:is_key(K, DiskKVs) of
+ case maps:is_key(K, IniMap) of
Review Comment:
excellent suggestion!
implemented in
https://github.com/apache/couchdb/pull/4813/commits/0f727cd1ed2de5e22fbc13d5a120a2122da74d80
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]