diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fabric_delete.erl | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/src/fabric_delete.erl b/src/fabric_delete.erl index 90108d3a..674f09ad 100644 --- a/src/fabric_delete.erl +++ b/src/fabric_delete.erl @@ -18,7 +18,7 @@ delete_db(DbName, Options) -> Parts = partitions:all_parts(DbName), RefPartMap = send_calls(DbName, Options, Parts), - Acc0 = {false, length(RefPartMap)}, + Acc0 = {true, length(RefPartMap)}, case fabric_util:receive_loop( RefPartMap, 1, fun handle_delete_msg/3, Acc0, 5000, infinity) of {ok, _Results} -> @@ -42,31 +42,19 @@ send_calls(DbName, Options, Parts) -> {Ref, Part} end, Parts). -handle_delete_msg(_, not_found, _) -> - {error, not_found}; -handle_delete_msg(_, {rexi_EXIT, _Reason}, {Complete, N, Parts}) -> - {ok, {Complete, N-1, Parts}}; -handle_delete_msg(_, {rexi_DOWN, _, _, _}, {Complete, _N, _Parts}) -> +handle_delete_msg(_, not_found, {NotFound, N}) -> + {ok, {NotFound, N-1}}; +handle_delete_msg(_, {rexi_EXIT, _Reason}, {NotFound, N}) -> + {ok, {NotFound, N-1}}; +handle_delete_msg(_, {rexi_DOWN, _, _, _}, _Acc) -> + {error, delete_db_fubar}; +handle_delete_msg(_, _, {NotFound, 1}) -> if - Complete -> {stop, ok}; - true -> {error, delete_db_fubar} + NotFound -> {stop, not_found}; + true -> {stop, ok} end; -handle_delete_msg(_, _, {true, 1, _Acc}) -> - {stop, ok}; -handle_delete_msg({_, #shard{range=[Beg,_]}}, {ok, _}, {false, 1, PartResults0}) -> - PartResults = lists:keyreplace(Beg, 1, PartResults0, {Beg, true}), - case is_complete(PartResults) of - true -> {stop, ok}; - false -> {error, delete_db_fubar} - end; -handle_delete_msg(_RefPart, {ok, _}, {true, N, Parts}) -> - {ok, {true, N-1, Parts}}; -handle_delete_msg({_Ref, #shard{range=[Beg,_]}}, {ok, _}, {false, Rem, PartResults0}) -> - PartResults = lists:keyreplace(Beg, 1, PartResults0, {Beg, true}), - {ok, {is_complete(PartResults), Rem-1, PartResults}}. - -is_complete(List) -> - lists:all(fun({_,Bool}) -> Bool end, List). +handle_delete_msg(_, ok, {_NotFound, N}) -> + {ok, {false, N-1}}. delete_fullmap(DbName) -> case couch_db:open(<<"dbs">>, []) of |