You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by mi...@apache.org on 2015/06/05 18:47:43 UTC

[03/13] couch-replicator commit: updated refs/heads/master to 80708a9

Verify that url really points to a database

This is a cherry-pick of:

https://github.com/cloudant/couch_replicator/commit/e73714196936c345d54158e674ab36cab20beeec


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/362b3fd4
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/362b3fd4
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/362b3fd4

Branch: refs/heads/master
Commit: 362b3fd490d00015ea13fe24b62b925c1acb6ea5
Parents: 2e6d5c1
Author: Robert Newson <rn...@apache.org>
Authored: Wed Dec 3 11:41:48 2014 +0000
Committer: Mike Wallace <mi...@apache.org>
Committed: Fri Jun 5 17:20:07 2015 +0100

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


http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/362b3fd4/src/couch_replicator_api_wrap.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_api_wrap.erl b/src/couch_replicator_api_wrap.erl
index 504a3d1..96947de 100644
--- a/src/couch_replicator_api_wrap.erl
+++ b/src/couch_replicator_api_wrap.erl
@@ -83,9 +83,20 @@ db_open(#httpdb{} = Db1, _Options, Create) ->
                     ok
                 end)
         end,
-        send_req(Db, [{method, head}],
-            fun(200, _, _) ->
-                {ok, Db};
+        send_req(Db, [{method, get}],
+            fun(200, _, {Props}) ->
+                UpdateSeq = get_value(<<"update_seq">>, Props),
+                InstanceStart = get_value(<<"instance_start_time">>, Props),
+                case {UpdateSeq, InstanceStart} of
+                    {undefined, _} ->
+                        throw({db_not_found, ?l2b(db_uri(Db))});
+                    {_, undefined} ->
+                        throw({db_not_found, ?l2b(db_uri(Db))});
+                    _ ->
+                        {ok, Db}
+                end;
+            (200, _, _Body) ->
+                 throw({db_not_found, ?l2b(db_uri(Db))});
             (401, _, _) ->
                 throw({unauthorized, ?l2b(db_uri(Db))});
             (_, _, _) ->