diff options
author | Adam Kocoloski <kocolosk@apache.org> | 2009-05-04 22:36:46 +0000 |
---|---|---|
committer | Adam Kocoloski <kocolosk@apache.org> | 2009-05-04 22:36:46 +0000 |
commit | 887c9b1a8b551272c3ca06906cfdc4fb901830a8 (patch) | |
tree | 1b84d4fcd544c920689194a0aacca50019c2388b | |
parent | ba94c9c5c85c82804faa91d8d2938539168ea965 (diff) |
use revisions when replicating attachments. Closes COUCHDB-337
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@771480 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/couchdb/couch_rep.erl | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/couchdb/couch_rep.erl b/src/couchdb/couch_rep.erl index 9d100d1f..f7b1e9ae 100644 --- a/src/couchdb/couch_rep.erl +++ b/src/couchdb/couch_rep.erl @@ -369,10 +369,11 @@ attachment_loop(ReqId) -> {ibrowse_async_response_end, ReqId} -> ok end. -attachment_stub_converter(DbS, Id, {Name, {stub, Type, Length}}) -> +attachment_stub_converter(DbS, Id, Rev, {Name, {stub, Type, Length}}) -> #http_db{uri=DbUrl, headers=Headers} = DbS, - % TODO worry about revisions - Url = DbUrl ++ url_encode(Id) ++ "/" ++ url_encode(?b2l(Name)), + {Pos, [RevId|_]} = Rev, + Url = lists:flatten([DbUrl, url_encode(Id), "/", url_encode(?b2l(Name)), + "?rev=", couch_doc:rev_to_str({Pos,RevId})]), ?LOG_DEBUG("Attachment URL ~p", [Url]), {ok, RcvFun} = make_attachment_stub_receiver(Url, Headers, Name, Type, Length), @@ -712,8 +713,9 @@ open_doc_revs(#http_db{uri=DbUrl, headers=Headers} = DbS, DocId, Revs0, fun({[{<<"missing">>, Rev}]}) -> {{not_found, missing}, couch_doc:parse_rev(Rev)}; ({[{<<"ok">>, JsonDoc}]}) -> - #doc{id=Id, attachments=Attach} = Doc = couch_doc:from_json_obj(JsonDoc), - Attach2 = [attachment_stub_converter(DbS,Id,A) || A <- Attach], + #doc{id=Id, revs=Rev, attachments=Attach} = Doc = + couch_doc:from_json_obj(JsonDoc), + Attach2 = [attachment_stub_converter(DbS,Id,Rev,A) || A <- Attach], {ok, Doc#doc{attachments=Attach2}} end, JsonResults), {ok, Results}; |