couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kocol...@apache.org
Subject svn commit: r771480 - /couchdb/trunk/src/couchdb/couch_rep.erl
Date Mon, 04 May 2009 22:36:46 GMT
Author: kocolosk
Date: Mon May  4 22:36:46 2009
New Revision: 771480

URL: http://svn.apache.org/viewvc?rev=771480&view=rev
Log:
use revisions when replicating attachments.  Closes COUCHDB-337

Modified:
    couchdb/trunk/src/couchdb/couch_rep.erl

Modified: couchdb/trunk/src/couchdb/couch_rep.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_rep.erl?rev=771480&r1=771479&r2=771480&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_rep.erl (original)
+++ couchdb/trunk/src/couchdb/couch_rep.erl Mon May  4 22:36:46 2009
@@ -369,10 +369,11 @@
         {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 @@
         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};



Mime
View raw message