summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrad Anderson <brad@cloudant.com>2010-05-27 11:37:11 -0400
committerBrad Anderson <brad@cloudant.com>2010-05-27 11:37:11 -0400
commit5b68d7349807b6540514ac8b506e80ede3d2fe3d (patch)
tree68b3b348afb46802ad4da357aa2e046578ea0fbd /src
parent00276b2582be213adf46c1f2333a65ceb86809e2 (diff)
more delete_db changes
Diffstat (limited to 'src')
-rw-r--r--src/fabric_delete.erl36
1 files changed, 12 insertions, 24 deletions
diff --git a/src/fabric_delete.erl b/src/fabric_delete.erl
index d1148e40..d2ee47e8 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({_, #part{b=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, #part{b=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