Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DEF5F116C8 for ; Thu, 28 Aug 2014 17:30:03 +0000 (UTC) Received: (qmail 13297 invoked by uid 500); 28 Aug 2014 17:30:02 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 13087 invoked by uid 500); 28 Aug 2014 17:30:02 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 12374 invoked by uid 99); 28 Aug 2014 17:30:02 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Aug 2014 17:30:02 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 315DEA04B01; Thu, 28 Aug 2014 17:30:02 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: chewbranca@apache.org To: commits@couchdb.apache.org Date: Thu, 28 Aug 2014 17:30:19 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [19/50] [abbrv] couch-replicator commit: updated refs/heads/1963-eunit-bigcouch to 3cf0b13 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/1963-eunit-bigcouch Commit: 777da3d1ed2d9ded240016273f3669c0660eaae9 Parents: a18aa43 Author: Paul J. Davis Authored: Wed Dec 11 11:58:04 2013 -0600 Committer: Robert Newson 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}.