Repository: couchdb-fabric Updated Branches: refs/heads/2643-fix-arity [created] a7cb8fd3e
Call the correct before_doc_update arity bug introduced in COUCHDB-510 fixes COUCHDB-2630 COUCHDB-2632 COUCHDB-2643 Project: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/commit/a7cb8fd3 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/tree/a7cb8fd3 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/diff/a7cb8fd3 Branch: refs/heads/2643-fix-arity Commit: a7cb8fd3edd4ec21ad0cec4a96a2c496ccc3e7a8 Parents: 985f136 Author: Robert Newson <[email protected]> Authored: Tue Mar 31 14:04:19 2015 +0100 Committer: Robert Newson <[email protected]> Committed: Tue Mar 31 14:04:19 2015 +0100 ---------------------------------------------------------------------- src/fabric_doc_update.erl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/a7cb8fd3/src/fabric_doc_update.erl ---------------------------------------------------------------------- diff --git a/src/fabric_doc_update.erl b/src/fabric_doc_update.erl index 4febe13..ad7d752 100644 --- a/src/fabric_doc_update.erl +++ b/src/fabric_doc_update.erl @@ -21,7 +21,7 @@ go(_, [], _) -> {ok, []}; go(DbName, AllDocs0, Opts) -> - AllDocs1 = before_doc_update(DbName, AllDocs0), + AllDocs1 = before_doc_update(DbName, AllDocs0, Opts), AllDocs = tag_docs(AllDocs1), validate_atomic_update(DbName, AllDocs, lists:member(all_or_nothing, Opts)), Options = lists:delete(all_or_nothing, Opts), @@ -98,12 +98,13 @@ handle_message({not_found, no_db_file} = X, Worker, Acc0) -> handle_message({bad_request, Msg}, _, _) -> throw({bad_request, Msg}). -before_doc_update(DbName, Docs) -> +before_doc_update(DbName, Docs, Opts) -> + Db = fake_db(Opts), case {is_replicator_db(DbName), is_users_db(DbName)} of {true, _} -> - lists:map(fun couch_replicator_manager:before_doc_update/1, Docs); + [couch_replicator_manager:before_doc_update(Doc, Db) || Doc <- Docs]; {_, true} -> - lists:map(fun couch_users_db:before_doc_update/1, Docs); + [couch_users_db:before_doc_update(Doc, Db) || Doc <- Docs]; _ -> Docs end. @@ -120,6 +121,10 @@ is_users_db(DbName) -> path_ends_with(Path, Suffix) -> Suffix == lists:last(binary:split(mem3:dbname(Path), <<"/">>, [global])). +fake_db(Opts) -> + {user_ctx, UserCtx} = lists:keyfind(user_ctx, 1, Opts), + #db{user_ctx = UserCtx}. + tag_docs([]) -> []; tag_docs([#doc{meta=Meta}=Doc | Rest]) ->
