rnewson commented on code in PR #4813:
URL: https://github.com/apache/couchdb/pull/4813#discussion_r1407930221
##########
src/config/src/config.erl:
##########
@@ -324,26 +337,15 @@ 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, _) ->
+ IniMap = ini_map(Config#config.ini_files),
+ % Update ets with list values, and delete those with ?DELETE markers.
+ maps:foreach(
+ fun({Sec, Key} = K, V) ->
VExisting = get(Sec, Key, V),
- ets:insert(?MODULE, {K, V}),
+ case V =:= ?DELETE of
Review Comment:
`=:=` looks odd here as the only difference between it and the more obvious
`==` applies to comparing floats and integers. `?DELETE` is an atom, so there
is no chance of that.
##########
src/config/src/config.erl:
##########
@@ -400,10 +400,21 @@ is_sensitive(Section, Key) ->
_ -> false
end.
+ini_map(IniFiles) ->
Review Comment:
nice.
--
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]