diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/couchdb/couch_config.erl | 27 | 
1 files changed, 22 insertions, 5 deletions
| diff --git a/src/couchdb/couch_config.erl b/src/couchdb/couch_config.erl index d590c321..c6fffe49 100644 --- a/src/couchdb/couch_config.erl +++ b/src/couchdb/couch_config.erl @@ -78,7 +78,7 @@ delete(Section, Key) ->  delete(Section, Key, Persist) when is_binary(Section) and is_binary(Key) ->      delete(?b2l(Section), ?b2l(Key), Persist);  delete(Section, Key, Persist) -> -    ?MODULE:set(Section, Key, "", Persist). +    gen_server:call(?MODULE, {delete, Section, Key, Persist}).  register(Fun) -> @@ -130,6 +130,18 @@ handle_call({set, Sec, Key, Val, Persist}, _From, Config) ->      end,      [catch F(Sec, Key, Val) || {_Pid, F} <- Config#config.notify_funs],      {reply, ok, Config}; +handle_call({delete, Sec, Key, Persist}, _From, Config) -> +    true = ets:delete(?MODULE, {Sec,Key}), +    case {Persist, Config#config.write_filename} of +        {true, undefined} -> +            ok; +        {true, FileName} -> +            couch_config_writer:save_to_file({{Sec, Key}, ""}, FileName); +        _ -> +            ok +    end, +    [catch F(Sec, Key, deleted) || {_Pid, F} <- Config#config.notify_funs], +    {reply, ok, Config};  handle_call({register, Fun, Pid}, _From, #config{notify_funs=PidFuns}=Config) ->      erlang:monitor(process, Pid),      % convert 1 and 2 arity to 3 arity @@ -194,10 +206,15 @@ parse_ini_file(IniFile) ->                  {ok, [ValueName|LineValues]} -> % yeehaw, got a line!                      RemainingLine = couch_util:implode(LineValues, "="),                      % removes comments -                    {ok, [LineValue | _Rest]} = -                        regexp:split(RemainingLine, " ;|\t;"), -                    {AccSectionName, -                [{{AccSectionName, ValueName}, LineValue} | AccValues]} +                    case regexp:split(RemainingLine, " ;|\t;") of +                    {ok, [[]]} -> +                        % empty line means delete this key +                        ets:delete(?MODULE, {AccSectionName, ValueName}), +                        {AccSectionName, AccValues};                         +                    {ok, [LineValue | _Rest]} -> +                        {AccSectionName, +                            [{{AccSectionName, ValueName}, LineValue} | AccValues]} +                    end                  end              end          end, {"", []}, Lines), | 
