Skip to content

Commit 0d130cf

Browse files
authored
Merge pull request #5776 from apache/config-put-value-if-changed
only put_value if value has changed
2 parents b9e6eda + b740bcf commit 0d130cf

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/config/src/config.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
% Reads CouchDB's ini file and gets queried for configuration parameters.
1414
% This module is initialized with a list of ini files that it consecutively
15-
% reads Key/Value pairs from and saves them in an ets table. If more an one
15+
% reads Key/Value pairs from and saves them as persistent terms. If more an one
1616
% ini file is specified, the last one is used to write changes that are made
1717
% with store/2 back to that ini file.
1818

@@ -364,16 +364,16 @@ handle_call({delete, Sec, Key, Persist, Reason}, _From, Config) ->
364364
handle_call(reload, _From, #config{} = Config) ->
365365
#config{ini_files_dirs = IniFilesDirs} = Config,
366366
IniFiles = expand_dirs(IniFilesDirs),
367-
% Update ets with ini values.
367+
% Update persistent term with ini values.
368368
IniMap = ini_map(IniFiles),
369369
maps:foreach(
370370
fun({Sec, Key}, V) ->
371371
VExisting = get_value(Sec, Key, undefined),
372-
put_value(Sec, Key, V),
373372
case V =:= VExisting of
374373
true ->
375374
ok;
376375
false ->
376+
put_value(Sec, Key, V),
377377
Msg = "Reload detected config change ~s.~s = ~p",
378378
Args = [Sec, Key, maybe_conceal(V, is_sensitive(Sec, Key))],
379379
couch_log:notice(Msg, Args),
@@ -383,7 +383,7 @@ handle_call(reload, _From, #config{} = Config) ->
383383
end,
384384
IniMap
385385
),
386-
% And remove anything in ets that wasn't on disk.
386+
% And remove anything in persistent terms that wasn't on disk.
387387
lists:foreach(
388388
fun
389389
({{Sec, Key}, _}) when not is_map_key({Sec, Key}, IniMap) ->

0 commit comments

Comments
 (0)