Updated Branches: refs/heads/1.1.x 3e2280bfd -> 5e2e0bb5a
create the system dbs straight away Fix spurious errors on startup now that couch_file logs its error results by asking that the system dbs be opened with the create option rather than catching a first failure opening without it. Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/5e2e0bb5 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/5e2e0bb5 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/5e2e0bb5 Branch: refs/heads/1.1.x Commit: 5e2e0bb5a8dfce77e74340de74790ba87195434a Parents: 3e2280b Author: Randall Leeds <rand...@apache.org> Authored: Fri Mar 23 05:32:47 2012 -0700 Committer: Randall Leeds <rand...@apache.org> Committed: Fri Mar 23 05:32:47 2012 -0700 ---------------------------------------------------------------------- src/couchdb/couch_auth_cache.erl | 22 ++++++++++------------ src/couchdb/couch_replication_manager.erl | 8 ++------ 2 files changed, 12 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/5e2e0bb5/src/couchdb/couch_auth_cache.erl ---------------------------------------------------------------------- diff --git a/src/couchdb/couch_auth_cache.erl b/src/couchdb/couch_auth_cache.erl index e0715b8..d5a61ea 100644 --- a/src/couchdb/couch_auth_cache.erl +++ b/src/couchdb/couch_auth_cache.erl @@ -367,7 +367,7 @@ exec_if_auth_db(Fun, DefRes) -> open_auth_db() -> [{auth_db_name, DbName}] = ets:lookup(?STATE, auth_db_name), - {ok, AuthDb} = ensure_users_db_exists(DbName, [sys_db]), + {ok, AuthDb} = ensure_users_db_exists(DbName), AuthDb. @@ -388,17 +388,15 @@ get_user_props_from_db(UserName) -> nil ). -ensure_users_db_exists(DbName, Options) -> - Options1 = [{user_ctx, #user_ctx{roles=[<<"_admin">>]}} | Options], - case couch_db:open(DbName, Options1) of - {ok, Db} -> - ensure_auth_ddoc_exists(Db, <<"_design/_auth">>), - {ok, Db}; - _Error -> - {ok, Db} = couch_db:create(DbName, Options1), - ok = ensure_auth_ddoc_exists(Db, <<"_design/_auth">>), - {ok, Db} - end. +ensure_users_db_exists(DbName) -> + Options1 = [ + create, + {user_ctx, #user_ctx{roles=[<<"_admin">>]}}, + sys_db + ], + {ok, Db} = couch_db:open(DbName, Options1), + ok = ensure_auth_ddoc_exists(Db, <<"_design/_auth">>), + {ok, Db}. ensure_auth_ddoc_exists(Db, DDocId) -> case couch_db:open_doc(Db, DDocId) of http://git-wip-us.apache.org/repos/asf/couchdb/blob/5e2e0bb5/src/couchdb/couch_replication_manager.erl ---------------------------------------------------------------------- diff --git a/src/couchdb/couch_replication_manager.erl b/src/couchdb/couch_replication_manager.erl index b3c6db1..1e4f04c 100644 --- a/src/couchdb/couch_replication_manager.erl +++ b/src/couchdb/couch_replication_manager.erl @@ -565,15 +565,11 @@ zone(Hr, Min) -> ensure_rep_db_exists() -> DbName = ?l2b(couch_config:get("replicator", "db", "_replicator")), Opts = [ + create, {user_ctx, #user_ctx{roles=[<<"_admin">>, <<"_replicator">>]}}, sys_db ], - case couch_db:open(DbName, Opts) of - {ok, Db} -> - Db; - _Error -> - {ok, Db} = couch_db:create(DbName, Opts) - end, + {ok, Db} = couch_db:open(DbName, Opts), ok = ensure_rep_ddoc_exists(Db, <<"_design/_replicator">>), {ok, Db}.