couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jch...@apache.org
Subject svn commit: r814851 - in /couchdb/branches/0.10.x/src/couchdb: couch_httpd_db.erl couch_rep_changes_feed.erl
Date Mon, 14 Sep 2009 20:57:03 GMT
Author: jchris
Date: Mon Sep 14 20:57:03 2009
New Revision: 814851

URL: http://svn.apache.org/viewvc?rev=814851&view=rev
Log:
backported deleted info on _changes for 0.10.x

Modified:
    couchdb/branches/0.10.x/src/couchdb/couch_httpd_db.erl
    couchdb/branches/0.10.x/src/couchdb/couch_rep_changes_feed.erl

Modified: couchdb/branches/0.10.x/src/couchdb/couch_httpd_db.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/0.10.x/src/couchdb/couch_httpd_db.erl?rev=814851&r1=814850&r2=814851&view=diff
==============================================================================
--- couchdb/branches/0.10.x/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/branches/0.10.x/src/couchdb/couch_httpd_db.erl Mon Sep 14 20:57:03 2009
@@ -147,30 +147,34 @@
     end.
 
 changes_enumerator(DocInfos, {_, _, FilterFun, Resp, "continuous"}) ->
-    [#doc_info{id=Id, high_seq=Seq}|_] = DocInfos,
+    [#doc_info{id=Id, high_seq=Seq, revs=[#rev_info{deleted=Del}|_]}|_] = DocInfos,
     Results0 = [FilterFun(DocInfo) || DocInfo <- DocInfos],
     Results = [Result || Result <- Results0, Result /= null],
     case Results of
     [] ->
         {ok, {Seq, nil, FilterFun, Resp, "continuous"}};
     _ ->
-        send_chunk(Resp, [?JSON_ENCODE({[{seq,Seq},{id,Id},{changes,Results}]})
-            |"\n"]),
+        send_chunk(Resp, [?JSON_ENCODE(changes_row(Seq, Id, Del, Results)) |"\n"]),
         {ok, {Seq, nil, FilterFun, Resp, "continuous"}}
     end;
 changes_enumerator(DocInfos, {_, Prepend, FilterFun, Resp, _}) ->
-    [#doc_info{id=Id, high_seq=Seq}|_] = DocInfos,
+    [#doc_info{id=Id, high_seq=Seq, revs=[#rev_info{deleted=Del}|_]}|_] = DocInfos,
     Results0 = [FilterFun(DocInfo) || DocInfo <- DocInfos],
     Results = [Result || Result <- Results0, Result /= null],
     case Results of
     [] ->
         {ok, {Seq, Prepend, FilterFun, Resp, nil}};
     _ ->
-        send_chunk(Resp, [Prepend, ?JSON_ENCODE({[{seq,Seq},{id,Id},
-            {changes,Results}]})]),
+        send_chunk(Resp, [Prepend, ?JSON_ENCODE(changes_row(Seq, Id, Del, Results))]),
         {ok, {Seq, <<",\n">>, FilterFun, Resp, nil}}
     end.
 
+changes_row(Seq, Id, Del, Results) ->
+    {[{seq,Seq},{id,Id},{changes,Results}] ++ deleted_item(Del)}.
+
+deleted_item(true) -> [{deleted,true}];
+deleted_item(_) -> [].
+
 send_changes(Req, Resp, Db, StartSeq, Prepend, ResponseType, FilterFun, End) ->
     Style = list_to_existing_atom(
             couch_httpd:qs_value(Req, "style", "main_only")),

Modified: couchdb/branches/0.10.x/src/couchdb/couch_rep_changes_feed.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/0.10.x/src/couchdb/couch_rep_changes_feed.erl?rev=814851&r1=814850&r2=814851&view=diff
==============================================================================
--- couchdb/branches/0.10.x/src/couchdb/couch_rep_changes_feed.erl (original)
+++ couchdb/branches/0.10.x/src/couchdb/couch_rep_changes_feed.erl Mon Sep 14 20:57:03 2009
@@ -277,9 +277,13 @@
 decode_row(<<",\n", Rest/binary>>) ->
     decode_row(Rest);
 decode_row(Row) ->
-    {[Seq, Id, {<<"changes">>,C}]} = ?JSON_DECODE(Row),
+    {Props} = ?JSON_DECODE(Row),
+    Seq = proplists:get_value(<<"seq">>, Props),
+    Id = proplists:get_value(<<"id">>, Props),
+    C = proplists:get_value(<<"changes">>, Props),
     C2 = [{[{<<"rev">>,couch_doc:parse_rev(R)}]} || {[{<<"rev">>,R}]}
<- C],
-    {[Seq, Id, {<<"changes">>,C2}]}.
+    {[{<<"seq">>, Seq}, {<<"id">>,Id}, {<<"changes">>,C2}]}.
+
 
 flush_updated_messages() ->
     receive updated -> flush_updated_messages()



Mime
View raw message