You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ii...@apache.org on 2016/08/10 19:36:10 UTC

[1/3] couch commit: updated refs/heads/master to 7ee0b81

Repository: couchdb-couch
Updated Branches:
  refs/heads/master 1df597fc2 -> 7ee0b8161


Fix the case when DbName contains path to db file

In the case when DbName contains the file name we need to remove .couch
extension in order to match ?DBNAME_REGEX.

COUCHDB-3080


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

Branch: refs/heads/master
Commit: 93c2c62f3e8e23d4e6fe1c48619eb767f229801b
Parents: 6b1796f
Author: ILYA Khlopotov <ii...@ca.ibm.com>
Authored: Mon Jul 25 15:23:30 2016 -0700
Committer: ILYA Khlopotov <ii...@ca.ibm.com>
Committed: Tue Aug 9 15:27:48 2016 -0700

----------------------------------------------------------------------
 src/couch_db.erl | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/93c2c62f/src/couch_db.erl
----------------------------------------------------------------------
diff --git a/src/couch_db.erl b/src/couch_db.erl
index 229bf4f..26c6ae7 100644
--- a/src/couch_db.erl
+++ b/src/couch_db.erl
@@ -1544,7 +1544,8 @@ validate_dbname(DbName) when is_binary(DbName) ->
         DbName, Normalized, fun validate_dbname_int/2).
 
 validate_dbname_int(DbName, Normalized) when is_binary(DbName) ->
-    case re:run(DbName, ?DBNAME_REGEX, [{capture,none}, dollar_endonly]) of
+    DbNoExt = maybe_remove_extension(DbName),
+    case re:run(DbNoExt, ?DBNAME_REGEX, [{capture,none}, dollar_endonly]) of
         match ->
             ok;
         nomatch ->
@@ -1563,23 +1564,23 @@ is_systemdb(DbName) when is_binary(DbName) ->
 -include_lib("eunit/include/eunit.hrl").
 
 setup() ->
-    ok = meck:new(couch_db_plugin, [passthrough]),
-    ok = meck:expect(couch_db_plugin, validate_dbname, fun(_, _) -> false end),
+    ok = meck:new(couch_epi, [passthrough]),
+    ok = meck:expect(couch_epi, decide, fun(_, _, _, _, _) -> no_decision end),
     ok.
 
 teardown(_) ->
-    (catch meck:unload(couch_db_plugin)).
+    (catch meck:unload(couch_epi)).
 
 validate_dbname_success_test_() ->
     Cases =
-        generate_cases_with_shards("long/co$mplex-/path+/_something")
+        generate_cases_with_shards("long/co$mplex-/path+/something")
         ++ generate_cases_with_shards("something")
         ++ lists:append(
             [generate_cases_with_shards(?b2l(SystemDb))
                 || SystemDb <- ?SYSTEM_DATABASES]),
     {
         foreach, fun setup/0, fun teardown/1,
-        [{test_name(A), fun() -> should_pass_validate_dbname(A) end} || {_, A} <- Cases]
+        [should_pass_validate_dbname(A) || {_, A} <- Cases]
     }.
 
 validate_dbname_fail_test_() ->
@@ -1589,7 +1590,7 @@ validate_dbname_fail_test_() ->
        ++ generate_cases_with_shards("long/co$mplex-/path+/some.thing"),
     {
         foreach, fun setup/0, fun teardown/1,
-        [{test_name(A), fun() -> should_fail_validate_dbname(A) end} || {_, A} <- Cases]
+        [should_fail_validate_dbname(A) || {_, A} <- Cases]
     }.
 
 normalize_dbname_test_() ->


[2/3] couch commit: updated refs/heads/master to 7ee0b81

Posted by ii...@apache.org.
Factor out maybe_remove_extension/1 function

COUCHDB-3080


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

Branch: refs/heads/master
Commit: 6b1796f9589eafeb0bc89b4f446915a1a71c7282
Parents: 1df597f
Author: ILYA Khlopotov <ii...@ca.ibm.com>
Authored: Mon Jul 25 15:22:04 2016 -0700
Committer: ILYA Khlopotov <ii...@ca.ibm.com>
Committed: Tue Aug 9 15:27:48 2016 -0700

----------------------------------------------------------------------
 src/couch_db.erl | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/6b1796f9/src/couch_db.erl
----------------------------------------------------------------------
diff --git a/src/couch_db.erl b/src/couch_db.erl
index 3eff99f..229bf4f 100644
--- a/src/couch_db.erl
+++ b/src/couch_db.erl
@@ -1519,13 +1519,17 @@ select_lt(V1, _V2) -> V1.
 normalize_dbname(DbName) when is_list(DbName) ->
     normalize_dbname(list_to_binary(DbName));
 normalize_dbname(DbName) when is_binary(DbName) ->
+    mem3:dbname(maybe_remove_extension(DbName)).
+
+maybe_remove_extension(DbName) ->
     case filename:extension(DbName) of
         <<".couch">> ->
-            mem3:dbname(filename:rootname(DbName));
+            filename:rootname(DbName);
         _ ->
-            mem3:dbname(DbName)
+            DbName
     end.
 
+
 -spec dbname_suffix(list() | binary()) -> binary().
 
 dbname_suffix(DbName) ->


[3/3] couch commit: updated refs/heads/master to 7ee0b81

Posted by ii...@apache.org.
Merge remote branch 'cloudant:3080-fix-validate_dbname'

This closes #188

Signed-off-by: ILYA Khlopotov <ii...@ca.ibm.com>


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

Branch: refs/heads/master
Commit: 7ee0b8161ea68530c567f98597019f3f38dcce1a
Parents: 1df597f 93c2c62
Author: ILYA Khlopotov <ii...@ca.ibm.com>
Authored: Wed Aug 10 12:35:58 2016 -0700
Committer: ILYA Khlopotov <ii...@ca.ibm.com>
Committed: Wed Aug 10 12:35:58 2016 -0700

----------------------------------------------------------------------
 src/couch_db.erl | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------