From c73a8da174f846e5fa401a25c47cb452f9a8bca6 Mon Sep 17 00:00:00 2001 From: Filipe David Borba Manana Date: Fri, 7 Jan 2011 11:43:46 +0000 Subject: Merged revision 1056274 from trunk More explicit and helpful file access permission errors Closes COUCHDB-966 git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1056275 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_config.erl | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/couchdb/couch_config.erl') diff --git a/src/couchdb/couch_config.erl b/src/couchdb/couch_config.erl index be53e3a3..34bb97fa 100644 --- a/src/couchdb/couch_config.erl +++ b/src/couchdb/couch_config.erl @@ -112,8 +112,7 @@ handle_call(all, _From, Config) -> Resp = lists:sort((ets:tab2list(?MODULE))), {reply, Resp, Config}; handle_call({set, Sec, Key, Val, Persist}, From, Config) -> - true = ets:insert(?MODULE, {{Sec, Key}, Val}), - case {Persist, Config#config.write_filename} of + Result = case {Persist, Config#config.write_filename} of {true, undefined} -> ok; {true, FileName} -> @@ -121,11 +120,17 @@ handle_call({set, Sec, Key, Val, Persist}, From, Config) -> _ -> ok end, - spawn_link(fun() -> - [catch F(Sec, Key, Val, Persist) || {_Pid, F} <- Config#config.notify_funs], - gen_server:reply(From, ok) - end), - {noreply, Config}; + case Result of + ok -> + true = ets:insert(?MODULE, {{Sec, Key}, Val}), + spawn_link(fun() -> + [catch F(Sec, Key, Val, Persist) || {_Pid, F} <- Config#config.notify_funs], + gen_server:reply(From, ok) + end), + {noreply, Config}; + _Error -> + {reply, Result, Config} + end; handle_call({delete, Sec, Key, Persist}, From, Config) -> true = ets:delete(?MODULE, {Sec,Key}), case {Persist, Config#config.write_filename} of -- cgit v1.2.3