From 7d8a8d69048955e97b6abe6118d28fda70fec271 Mon Sep 17 00:00:00 2001 From: benoitc Date: Sat, 10 Sep 2011 11:19:20 +0200 Subject: Add missing database 'created' event. The `created` event is emitted on apache couchdb when a database is created. This patch re-add it to bigcouch. --- apps/couch/src/couch_server.erl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'apps/couch/src/couch_server.erl') diff --git a/apps/couch/src/couch_server.erl b/apps/couch/src/couch_server.erl index cfe0b5fc..f9c960c5 100644 --- a/apps/couch/src/couch_server.erl +++ b/apps/couch/src/couch_server.erl @@ -217,7 +217,7 @@ open_async(Server, From, DbName, Filepath, Options) -> Parent = self(), Opener = spawn_link(fun() -> Res = couch_db:start_link(DbName, Filepath, Options), - gen_server:call(Parent, {open_result, DbName, Res}, infinity), + gen_server:call(Parent, {open_result, DbName, Res, Options}, infinity), unlink(Parent) end), % icky hack of field values - compactor_pid used to store clients @@ -244,15 +244,21 @@ handle_call({set_max_dbs_open, Max}, _From, Server) -> {reply, ok, Server#server{max_dbs_open=Max}}; handle_call(get_server, _From, Server) -> {reply, {ok, Server}, Server}; -handle_call({open_result, DbName, {ok, Db}}, _From, Server) -> +handle_call({open_result, DbName, {ok, Db}, Options}, _From, Server) -> link(Db#db.main_pid), % icky hack of field values - compactor_pid used to store clients [#db{compactor_pid=Froms}] = ets:lookup(couch_dbs, DbName), [gen_server:reply(From, {ok, Db}) || From <- Froms], true = ets:insert(couch_dbs, Db), true = ets:insert(couch_lru, {DbName, now()}), + case lists:member(create, Options) of + true -> + couch_db_update_notifier:notify({created, DbName}); + false -> + ok + end, {reply, ok, Server}; -handle_call({open_result, DbName, Error}, _From, Server) -> +handle_call({open_result, DbName, Error, _Options}, _From, Server) -> % icky hack of field values - compactor_pid used to store clients [#db{compactor_pid=Froms}] = ets:lookup(couch_dbs, DbName), [gen_server:reply(From, Error) || From <- Froms], -- cgit v1.2.3