diff options
Diffstat (limited to 'src/couch_replicator/src/couch_replicator_doc_processor.erl')
-rw-r--r-- | src/couch_replicator/src/couch_replicator_doc_processor.erl | 51 |
1 files changed, 3 insertions, 48 deletions
diff --git a/src/couch_replicator/src/couch_replicator_doc_processor.erl b/src/couch_replicator/src/couch_replicator_doc_processor.erl index d3c001f26..1b43598da 100644 --- a/src/couch_replicator/src/couch_replicator_doc_processor.erl +++ b/src/couch_replicator/src/couch_replicator_doc_processor.erl @@ -264,7 +264,9 @@ code_change(_OldVsn, State, _Extra) -> % same document. -spec updated_doc(db_doc_id(), #rep{}, filter_type()) -> ok. updated_doc(Id, Rep, Filter) -> - case normalize_rep(current_rep(Id)) == normalize_rep(Rep) of + NormCurRep = couch_replicator_utils:normalize_rep(current_rep(Id)), + NormNewRep = couch_replicator_utils:normalize_rep(Rep), + case NormCurRep == NormNewRep of false -> removed_doc(Id), Row = #rdoc{ @@ -304,25 +306,6 @@ current_rep({DbName, DocId}) when is_binary(DbName), is_binary(DocId) -> end. -% Normalize a #rep{} record such that it doesn't contain time dependent fields -% pids (like httpc pools), and options / props are sorted. This function would -% used during comparisons. --spec normalize_rep(#rep{} | nil) -> #rep{} | nil. -normalize_rep(nil) -> - nil; - -normalize_rep(#rep{} = Rep)-> - #rep{ - source = couch_replicator_api_wrap:normalize_db(Rep#rep.source), - target = couch_replicator_api_wrap:normalize_db(Rep#rep.target), - options = Rep#rep.options, % already sorted in make_options/1 - type = Rep#rep.type, - view = Rep#rep.view, - doc_id = Rep#rep.doc_id, - db_name = Rep#rep.db_name - }. - - -spec worker_returned(reference(), db_doc_id(), rep_start_result()) -> ok. worker_returned(Ref, Id, {ok, RepId}) -> case ets:lookup(?MODULE, Id) of @@ -819,34 +802,6 @@ t_cluster_membership_foldl() -> end). -normalize_rep_test_() -> - { - setup, - fun() -> meck:expect(config, get, - fun(_, _, Default) -> Default end) - end, - fun(_) -> meck:unload() end, - ?_test(begin - EJson1 = {[ - {<<"source">>, <<"http://host.com/source_db">>}, - {<<"target">>, <<"local">>}, - {<<"doc_ids">>, [<<"a">>, <<"c">>, <<"b">>]}, - {<<"other_field">>, <<"some_value">>} - ]}, - Rep1 = couch_replicator_docs:parse_rep_doc_without_id(EJson1), - EJson2 = {[ - {<<"other_field">>, <<"unrelated">>}, - {<<"target">>, <<"local">>}, - {<<"source">>, <<"http://host.com/source_db">>}, - {<<"doc_ids">>, [<<"c">>, <<"a">>, <<"b">>]}, - {<<"other_field2">>, <<"unrelated2">>} - ]}, - Rep2 = couch_replicator_docs:parse_rep_doc_without_id(EJson2), - ?assertEqual(normalize_rep(Rep1), normalize_rep(Rep2)) - end) - }. - - get_worker_ref_test_() -> { setup, |