diff options
author | Brad Anderson <brad@sankatygroup.com> | 2010-09-01 11:49:01 -0400 |
---|---|---|
committer | Brad Anderson <brad@sankatygroup.com> | 2010-09-01 11:49:01 -0400 |
commit | 5a77f1120c80b62e3c1534eeaad53fb2dbf77b7b (patch) | |
tree | 2aca0bd9db95eb406742c4dec554db19518f759c /apps/chttpd/src | |
parent | 53a652596ad2d686b8c28637807a1260dc4c5ad6 (diff) |
pass W from Req to fabric properly
Diffstat (limited to 'apps/chttpd/src')
-rw-r--r-- | apps/chttpd/src/chttpd_db.erl | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/apps/chttpd/src/chttpd_db.erl b/apps/chttpd/src/chttpd_db.erl index 040de749..58897e0a 100644 --- a/apps/chttpd/src/chttpd_db.erl +++ b/apps/chttpd/src/chttpd_db.erl @@ -544,7 +544,10 @@ db_doc_req(#httpd{method='PUT', user_ctx=Ctx}=Req, Db, DocId) -> update_type = UpdateType } = parse_doc_query(Req), couch_doc:validate_docid(DocId), - + + W = couch_httpd:qs_value(Req, "w", couch_config:get("cluster", "w", "2")), + Options = [{user_ctx,Ctx}, {w,W}], + Loc = absolute_uri(Req, [$/, Db#db.name, $/, DocId]), RespHeaders = [{"Location", Loc}], case couch_util:to_list(couch_httpd:header_value(Req, "Content-Type")) of @@ -558,9 +561,9 @@ db_doc_req(#httpd{method='PUT', user_ctx=Ctx}=Req, Db, DocId) -> "ok" -> % batch Doc = couch_doc_from_req(Req, DocId, couch_httpd:json_body(Req)), - + spawn(fun() -> - case catch(fabric:update_doc(Db, Doc, [{user_ctx,Ctx}])) of + case catch(fabric:update_doc(Db, Doc, Options)) of {ok, _} -> ok; Error -> ?LOG_INFO("Batch doc error (~s): ~p",[DocId, Error]) @@ -692,13 +695,14 @@ update_doc(Req, Db, DocId, Doc, Headers) -> update_doc(#httpd{user_ctx=Ctx} = Req, Db, DocId, #doc{deleted=Deleted}=Doc, Headers, UpdateType) -> + W = couch_httpd:qs_value(Req, "w", couch_config:get("cluster", "w", "2")), case couch_httpd:header_value(Req, "X-Couch-Full-Commit") of "true" -> - Options = [full_commit, UpdateType, {user_ctx,Ctx}]; + Options = [full_commit, UpdateType, {user_ctx,Ctx}, {w,W}]; "false" -> - Options = [delay_commit, UpdateType, {user_ctx,Ctx}]; + Options = [delay_commit, UpdateType, {user_ctx,Ctx}, {w,W}]; _ -> - Options = [UpdateType, {user_ctx,Ctx}] + Options = [UpdateType, {user_ctx,Ctx}, {w,W}] end, {ok, NewRev} = fabric:update_doc(Db, Doc, Options), NewRevStr = couch_doc:rev_to_str(NewRev), |