You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by kx...@apache.org on 2015/02/26 21:31:47 UTC
[3/5] couch commit: updated refs/heads/master to 04fb140
Move list of system databases to the macro
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/b6b887d9
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/b6b887d9
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/b6b887d9
Branch: refs/heads/master
Commit: b6b887d9c7a45b3ed3bf7b4a965b86bed42b380c
Parents: 7950604
Author: Alexander Shorin <kx...@apache.org>
Authored: Wed Feb 25 21:59:07 2015 +0300
Committer: Alexander Shorin <kx...@apache.org>
Committed: Wed Feb 25 21:59:07 2015 +0300
----------------------------------------------------------------------
include/couch_db.hrl | 8 ++++++++
src/couch_server.erl | 13 ++++---------
2 files changed, 12 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/b6b887d9/include/couch_db.hrl
----------------------------------------------------------------------
diff --git a/include/couch_db.hrl b/include/couch_db.hrl
index 9eb03ab..5a11bb1 100644
--- a/include/couch_db.hrl
+++ b/include/couch_db.hrl
@@ -40,6 +40,14 @@
-define(ADMIN_USER, #user_ctx{roles=[<<"_admin">>]}).
-define(ADMIN_CTX, {user_ctx, ?ADMIN_USER}).
+-define(SYSTEM_DATABASES, [
+ "_dbs",
+ "_metadata",
+ "_nodes",
+ "_replicator",
+ "_users"
+]).
+
-type branch() :: {Key::term(), Value::term(), Tree::term()}.
-type path() :: {Start::pos_integer(), branch()}.
http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/b6b887d9/src/couch_server.erl
----------------------------------------------------------------------
diff --git a/src/couch_server.erl b/src/couch_server.erl
index 0f7fab0..34ca3d6 100644
--- a/src/couch_server.erl
+++ b/src/couch_server.erl
@@ -148,15 +148,10 @@ path_ends_with(Path, Suffix) ->
check_dbname(#server{dbname_regexp=RegExp}, DbName) ->
case re:run(DbName, RegExp, [{capture, none}]) of
nomatch ->
- case DbName of
- "_users" -> ok;
- "_replicator" -> ok;
- "_dbs" -> ok;
- "_nodes" -> ok;
- "_metadata" -> ok;
- _Else ->
- {error, illegal_database_name, DbName}
- end;
+ case lists:member(DbName, ?SYSTEM_DATABASES) of
+ true -> ok;
+ false -> {error, illegal_database_name, DbName}
+ end;
match ->
ok
end.