couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [20/37] couch-replicator commit: updated refs/heads/master to aafb5f9
Date Thu, 28 Aug 2014 12:15:51 GMT
Fallback to using source seq for Apache CouchDB

If the update_seq is a number we assume that the source server is Apache
CouchDB so we fall back to comparing the current update_seq against the
update_seq value in the database info blob.

BugzId: 26015


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/commit/777da3d1
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/777da3d1
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/777da3d1

Branch: refs/heads/master
Commit: 777da3d1ed2d9ded240016273f3669c0660eaae9
Parents: a18aa43
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Wed Dec 11 11:58:04 2013 -0600
Committer: Robert Newson <rnewson@apache.org>
Committed: Tue Jul 29 15:18:00 2014 +0100

----------------------------------------------------------------------
 src/couch_replicator_api_wrap.erl | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/777da3d1/src/couch_replicator_api_wrap.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_api_wrap.erl b/src/couch_replicator_api_wrap.erl
index 3b2e1de..fd8edc4 100644
--- a/src/couch_replicator_api_wrap.erl
+++ b/src/couch_replicator_api_wrap.erl
@@ -125,15 +125,24 @@ get_db_info(#db{name = DbName, user_ctx = UserCtx}) ->
     {ok, [{couch_util:to_binary(K), V} || {K, V} <- Info]}.
 
 
+get_pending_count(#httpdb{} = Db, Seq) when is_number(Seq) ->
+    % Source looks like Apache CouchDB and not Cloudant so we fall
+    % back to using update sequence differences.
+    send_req(Db, [], fun(200, _, {Props}) ->
+        case get_value(<<"update_seq">>, Props) of
+            UpdateSeq when is_number(UpdateSeq) ->
+                {ok, UpdateSeq - Seq};
+            _ ->
+                {ok, null}
+        end
+    end);
 get_pending_count(#httpdb{} = Db, Seq) ->
-    send_req(
-        Db,
-        [{path, "_changes"}, {qs, [{"since", Seq}, {"limit", "0"}]}],
-        fun(200, _, {Props}) ->
-            {ok, couch_util:get_value(<<"pending">>, Props, null)}
-        end);
-get_pending_count(#db{name=DbName, user_ctx = UserCtx}, Seq) ->
-    {ok, Db} = couch_db:open(DbName, [{user_ctx, UserCtx}]),
+    Options = [{path, "_changes"}, {qs, [{"since", Seq}, {"limit", "0"}]}],
+    send_req(Db, Options, fun(200, _, {Props}) ->
+        {ok, couch_util:get_value(<<"pending">>, Props, null)}
+    end);
+get_pending_count(#db{name=DbName}=Db, Seq) when is_number(Seq) ->
+    {ok, Db} = couch_db:open(DbName, [{user_ctx, Db#db.user_ctx}]),
     Pending = couch_db:count_changes_since(Db, Seq),
     couch_db:close(Db),
     {ok, Pending}.


Mime
View raw message