couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r1125317 - /couchdb/trunk/src/couchdb/couch_replication_manager.erl
Date Fri, 20 May 2011 10:52:45 GMT
Author: fdmanana
Date: Fri May 20 10:52:45 2011
New Revision: 1125317

URL: http://svn.apache.org/viewvc?rev=1125317&view=rev
Log:
Replication manager: don't update doc if new state == current state

This is to avoid unncessary updates.

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

Modified: couchdb/trunk/src/couchdb/couch_replication_manager.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_replication_manager.erl?rev=1125317&r1=1125316&r2=1125317&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_replication_manager.erl (original)
+++ couchdb/trunk/src/couchdb/couch_replication_manager.erl Fri May 20 10:52:45 2011
@@ -468,13 +468,18 @@ update_rep_doc(RepDocId, KVs) ->
 
 update_rep_doc(RepDb, #doc{body = {RepDocBody}} = RepDoc, KVs) ->
     NewRepDocBody = lists:foldl(
-        fun({<<"_replication_state">> = K, _V} = KV, Body) ->
-                Body1 = lists:keystore(K, 1, Body, KV),
-                {Mega, Secs, _} = erlang:now(),
-                UnixTime = Mega * 1000000 + Secs,
-                lists:keystore(
-                    <<"_replication_state_time">>, 1, Body1,
-                    {<<"_replication_state_time">>, UnixTime});
+        fun({<<"_replication_state">> = K, State} = KV, Body) ->
+                case get_value(K, Body) of
+                State ->
+                    Body;
+                _ ->
+                    Body1 = lists:keystore(K, 1, Body, KV),
+                    {Mega, Secs, _} = erlang:now(),
+                    UnixTime = Mega * 1000000 + Secs,
+                    lists:keystore(
+                        <<"_replication_state_time">>, 1, Body1,
+                        {<<"_replication_state_time">>, UnixTime})
+                end;
             ({K, _V} = KV, Body) ->
                 lists:keystore(K, 1, Body, KV)
         end,



Mime
View raw message