You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2018/10/23 13:22:35 UTC
[couchdb] branch master updated: expose is_system_db_name
This is an automated email from the ASF dual-hosted git repository.
garren pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/master by this push:
new d02d614 expose is_system_db_name
d02d614 is described below
commit d02d6140afa0b2eca42b9d20bf2d15f6058e9be9
Author: Garren Smith <ga...@gmail.com>
AuthorDate: Fri Oct 19 11:13:11 2018 +0200
expose is_system_db_name
Expose is_system_db_name as a way to verify if a binary string is the
name of a system database.
---
src/couch/src/couch_db.erl | 13 +++++++------
src/couch/src/couch_doc.erl | 2 +-
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/couch/src/couch_db.erl b/src/couch/src/couch_db.erl
index 4d76cee..57e3951 100644
--- a/src/couch/src/couch_db.erl
+++ b/src/couch/src/couch_db.erl
@@ -56,6 +56,7 @@
is_db/1,
is_system_db/1,
is_clustered/1,
+ is_system_db_name/1,
set_revs_limit/2,
set_purge_infos_limit/2,
@@ -1729,15 +1730,15 @@ validate_dbname_int(DbName, Normalized) when is_binary(DbName) ->
match ->
ok;
nomatch ->
- case is_systemdb(Normalized) of
+ case is_system_db_name(Normalized) of
true -> ok;
false -> {error, {illegal_database_name, DbName}}
end
end.
-is_systemdb(DbName) when is_list(DbName) ->
- is_systemdb(?l2b(DbName));
-is_systemdb(DbName) when is_binary(DbName) ->
+is_system_db_name(DbName) when is_list(DbName) ->
+ is_system_db_name(?l2b(DbName));
+is_system_db_name(DbName) when is_binary(DbName) ->
Normalized = normalize_dbname(DbName),
Suffix = filename:basename(Normalized),
case {filename:dirname(Normalized), lists:member(Suffix, ?SYSTEM_DATABASES)} of
@@ -1860,7 +1861,7 @@ dbname_suffix_test_() ->
[{test_name({Expected, Db}), ?_assertEqual(Expected, dbname_suffix(Db))}
|| {Expected, Db} <- WithExpected].
-is_systemdb_test_() ->
+is_system_db_name_test_() ->
Cases = lists:append([
generate_cases_with_shards("long/co$mplex-/path+/" ++ ?b2l(Db))
|| Db <- ?SYSTEM_DATABASES]
@@ -1869,7 +1870,7 @@ is_systemdb_test_() ->
WithExpected = [{?l2b(filename:basename(filename:rootname(Arg))), Db}
|| {Arg, Db} <- Cases],
[{test_name({Expected, Db}) ++ " in ?SYSTEM_DATABASES",
- ?_assert(is_systemdb(Db))} || {Expected, Db} <- WithExpected].
+ ?_assert(is_system_db_name(Db))} || {Expected, Db} <- WithExpected].
should_pass_validate_dbname(DbName) ->
{test_name(DbName), ?_assertEqual(ok, validate_dbname(DbName))}.
diff --git a/src/couch/src/couch_doc.erl b/src/couch/src/couch_doc.erl
index f960ec5..e5ad9e9 100644
--- a/src/couch/src/couch_doc.erl
+++ b/src/couch/src/couch_doc.erl
@@ -200,7 +200,7 @@ parse_revs(_) ->
validate_docid(DocId, DbName) ->
case DbName =:= ?l2b(config:get("mem3", "shards_db", "_dbs")) andalso
- lists:member(DocId, ?SYSTEM_DATABASES) of
+ couch_db:is_system_db_name(DocId) of
true ->
ok;
false ->