summaryrefslogtreecommitdiff
path: root/src/couch_mrview/src/couch_mrview_index.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/couch_mrview/src/couch_mrview_index.erl')
-rw-r--r--src/couch_mrview/src/couch_mrview_index.erl29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/couch_mrview/src/couch_mrview_index.erl b/src/couch_mrview/src/couch_mrview_index.erl
index c96d87173..8e844e80c 100644
--- a/src/couch_mrview/src/couch_mrview_index.erl
+++ b/src/couch_mrview/src/couch_mrview_index.erl
@@ -20,6 +20,7 @@
-export([index_file_exists/1]).
-export([update_local_purge_doc/2, verify_index_exists/2]).
-export([ensure_local_purge_docs/2]).
+-export([format_status/2]).
-include_lib("couch/include/couch_db.hrl").
-include_lib("couch_mrview/include/couch_mrview.hrl").
@@ -133,6 +134,12 @@ open(Db, State0) ->
NewSt = couch_mrview_util:reset_index(Db, Fd, State),
ensure_local_purge_doc(Db, NewSt),
{ok, NewSt};
+ {ok, Else} ->
+ couch_log:error("~s has a bad header: got ~p",
+ [IndexFName, Else]),
+ NewSt = couch_mrview_util:reset_index(Db, Fd, State),
+ ensure_local_purge_doc(Db, NewSt),
+ {ok, NewSt};
no_valid_header ->
NewSt = couch_mrview_util:reset_index(Db, Fd, State),
ensure_local_purge_doc(Db, NewSt),
@@ -252,16 +259,7 @@ set_partitioned(Db, State) ->
DbPartitioned = couch_db:is_partitioned(Db),
ViewPartitioned = couch_util:get_value(
<<"partitioned">>, DesignOpts, DbPartitioned),
- IsPartitioned = case {DbPartitioned, ViewPartitioned} of
- {true, true} ->
- true;
- {true, false} ->
- false;
- {false, false} ->
- false;
- _ ->
- throw({bad_request, <<"invalid partition option">>})
- end,
+ IsPartitioned = DbPartitioned andalso ViewPartitioned,
State#mrst{partitioned = IsPartitioned}.
@@ -318,3 +316,14 @@ update_local_purge_doc(Db, State, PSeq) ->
BaseDoc
end,
couch_db:update_doc(Db, Doc, []).
+
+format_status(_Opt, [_PDict, State]) ->
+ Scrubbed = State#mrst{
+ lib = nil,
+ views = nil,
+ id_btree = nil,
+ doc_acc = nil,
+ doc_queue = nil,
+ write_queue = nil
+ },
+ ?record_to_keyval(mrst, Scrubbed).