@@ -154,13 +154,13 @@ handle_call({async_error, {DbName, _DDocId, Sig}, Error}, _From, State) ->
154154 [gen_server :reply (From , Error ) || From <- Waiters ],
155155 ets :delete (? BY_SIG , {DbName , Sig }),
156156 {reply , ok , State };
157- handle_call ({reset_indexes , DbName }, _From , State ) ->
158- reset_indexes (DbName , State # st .root_dir ),
157+ handle_call ({reset_indexes , Options }, _From , State ) ->
158+ reset_indexes (Options , State # st .root_dir ),
159159 {reply , ok , State }.
160160
161161
162- handle_cast ({reset_indexes , DbName }, State ) ->
163- reset_indexes (DbName , State # st .root_dir ),
162+ handle_cast ({reset_indexes , Options }, State ) ->
163+ reset_indexes (Options , State # st .root_dir ),
164164 {noreply , State }.
165165
166166handle_info ({'EXIT' , Pid , Reason }, Server ) ->
@@ -219,7 +219,8 @@ new_index({Mod, IdxState, DbName, Sig}) ->
219219 end .
220220
221221
222- reset_indexes (DbName , Root ) ->
222+ reset_indexes (Options , Root ) ->
223+ DbName = couch_util :get_value (db_name , Options ),
223224 % shutdown all the updaters and clear the files, the db got changed
224225 Fun = fun ({_ , {DDocId , Sig }}) ->
225226 [{_ , Pid }] = ets :lookup (? BY_SIG , {DbName , Sig }),
@@ -230,7 +231,7 @@ reset_indexes(DbName, Root) ->
230231 end ,
231232 lists :foreach (Fun , ets :lookup (? BY_DB , DbName )),
232233 Path = couch_index_util :index_dir (" " , DbName ),
233- couch_file :nuke_dir (Root , Path ).
234+ couch_file :nuke_dir (Root , Path , Options ).
234235
235236
236237add_to_ets (DbName , Sig , DDocId , Pid ) ->
@@ -246,10 +247,10 @@ rem_from_ets(DbName, Sig, DDocId, Pid) ->
246247
247248
248249handle_db_event (DbName , created , St ) ->
249- gen_server :cast (? MODULE , {reset_indexes , DbName }),
250+ gen_server :cast (? MODULE , {reset_indexes , [{ db_name , DbName }, { context , []}] }),
250251 {ok , St };
251252handle_db_event (DbName , deleted , St ) ->
252- gen_server :cast (? MODULE , {reset_indexes , DbName }),
253+ gen_server :cast (? MODULE , {reset_indexes , [{ db_name , DbName }, { context , delete }] }),
253254 {ok , St };
254255handle_db_event (DbName , {ddoc_updated , DDocId }, St ) ->
255256 lists :foreach (fun ({_DbName , {_DDocId , Sig }}) ->
0 commit comments