couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r993064 - /couchdb/branches/new_replicator/src/couchdb/couch_replicate.erl
Date Mon, 06 Sep 2010 15:08:38 GMT
Author: fdmanana
Date: Mon Sep  6 15:08:38 2010
New Revision: 993064

URL: http://svn.apache.org/viewvc?rev=993064&view=rev
Log:
New replicator: deal with errors (db_not_found, unauthorized) when checking the source DB's
last seq.

Modified:
    couchdb/branches/new_replicator/src/couchdb/couch_replicate.erl

Modified: couchdb/branches/new_replicator/src/couchdb/couch_replicate.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/new_replicator/src/couchdb/couch_replicate.erl?rev=993064&r1=993063&r2=993064&view=diff
==============================================================================
--- couchdb/branches/new_replicator/src/couchdb/couch_replicate.erl (original)
+++ couchdb/branches/new_replicator/src/couchdb/couch_replicate.erl Mon Sep  6 15:08:38 2010
@@ -88,7 +88,7 @@ do_replication_loop(#rep{options = Optio
     Continuous = get_value(continuous, Options, false),
     Seq = case {DocIds, Continuous} of
     {undefined, false} ->
-        last_seq(Src);
+        last_seq(Src, Rep#rep.user_ctx);
     _ ->
         undefined
     end,
@@ -122,12 +122,15 @@ maybe_retry(RepResult, _Rep, _Seq) ->
     RepResult.
 
 
-last_seq(DbName) ->
-    {ok, Db} = couch_api_wrap:db_open(
-        DbName, [{user_ctx, #user_ctx{roles = [<<"_admin">>]}}]),
-    {ok, DbInfo} = couch_api_wrap:get_db_info(Db),
-    couch_api_wrap:db_close(Db),
-    get_value(<<"update_seq">>, DbInfo).
+last_seq(DbName, UserCtx) ->
+    case (catch couch_api_wrap:db_open(DbName, [{user_ctx, UserCtx}])) of
+    {ok, Db} ->
+        {ok, DbInfo} = couch_api_wrap:get_db_info(Db),
+        couch_api_wrap:db_close(Db),
+        get_value(<<"update_seq">>, DbInfo);
+    _ ->
+        undefined
+    end.
 
 
 start_replication(#rep{id = {BaseId, Extension}} = Rep) ->



Mime
View raw message