couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject svn commit: r1097048 - in /couchdb/trunk/src/couchdb: couch_db_updater.erl couch_doc.erl
Date Wed, 27 Apr 2011 09:19:29 GMT
Author: rnewson
Date: Wed Apr 27 09:19:29 2011
New Revision: 1097048

URL: http://svn.apache.org/viewvc?rev=1097048&view=rev
Log:
COUCHDB-1141 - drop body if document is deleted.

Modified:
    couchdb/trunk/src/couchdb/couch_db_updater.erl
    couchdb/trunk/src/couchdb/couch_doc.erl

Modified: couchdb/trunk/src/couchdb/couch_db_updater.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db_updater.erl?rev=1097048&r1=1097047&r2=1097048&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db_updater.erl (original)
+++ couchdb/trunk/src/couchdb/couch_db_updater.erl Wed Apr 27 09:19:29 2011
@@ -820,6 +820,11 @@ copy_docs(Db, #db{updater_fd = DestFd} =
             Info#full_doc_info{rev_tree=couch_key_tree:map(
                 fun(_, _, branch) ->
                     ?REV_MISSING;
+		(_Rev, LeafVal, leaf) when element(1, LeafVal) ->
+                    Seq = element(3, LeafVal),
+                    {ok, Pos, SummarySize} =
+                        couch_file:append_term_md5(DestFd, {{[]}, []}),
+                    {true, Pos, Seq, SummarySize};
                 (_Rev, LeafVal, leaf) ->
                     IsDel = element(1, LeafVal),
                     Sp = element(2, LeafVal),

Modified: couchdb/trunk/src/couchdb/couch_doc.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_doc.erl?rev=1097048&r1=1097047&r2=1097048&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_doc.erl (original)
+++ couchdb/trunk/src/couchdb/couch_doc.erl Wed Apr 27 09:19:29 2011
@@ -143,11 +143,16 @@ to_json_obj(#doc{id=Id,deleted=Del,body=
     }.
 
 from_json_obj({Props}) ->
-    transfer_fields(Props, #doc{body=[]});
+    clean_if_deleted(transfer_fields(Props, #doc{body=[]}));
 
 from_json_obj(_Other) ->
     throw({bad_request, "Document must be a JSON object"}).
 
+clean_if_deleted(#doc{deleted=true}=Doc) ->
+    Doc#doc{atts=[], body={[]}};
+clean_if_deleted(Doc) ->
+    Doc.
+
 parse_revid(RevId) when size(RevId) =:= 32 ->
     RevInt = erlang:list_to_integer(?b2l(RevId), 16),
      <<RevInt:128>>;



Mime
View raw message