Skip to content

Commit

Permalink
Merge branch 'master' into view_changes
Browse files Browse the repository at this point in the history
Conflicts:
	apps/couch_changes/include/couch_changes.hrl
	apps/couch_changes/src/couch_changes.erl
	apps/couch_changes/src/couch_httpd_changes.erl
	apps/couch_replicator/src/couch_replicator_api_wrap.erl
  • Loading branch information
benoitc committed May 26, 2012
2 parents 56bb344 + f8e221c commit e942d68
Show file tree
Hide file tree
Showing 35 changed files with 864 additions and 75 deletions.
3 changes: 1 addition & 2 deletions Makefile
@@ -1,7 +1,6 @@
ERLC ?= erlc


all: check
all: deps compile

compile:
rebar -C rebar_dev.config compile
Expand Down
Empty file added apps/couch/priv/.keep
Empty file.
4 changes: 1 addition & 3 deletions apps/couch/src/couch.app.src
Expand Up @@ -12,12 +12,10 @@
couch_rep_sup,
couch_secondary_services,
couch_server,
couch_stats_aggregator,
couch_stats_collector,
couch_task_status
]},
{mod, {couch_app, []}},

{applications, [kernel, stdlib, crypto, lager, sasl, public_key, ssl,
inets, os_mon]}
inets, os_mon, couch_stats]}
]}.
8 changes: 8 additions & 0 deletions apps/couch/src/couch_db.erl
Expand Up @@ -335,6 +335,14 @@ check_is_admin(#db{user_ctx=#user_ctx{name=Name,roles=Roles}}=Db) ->
ok
end.

check_is_member(#db{name = <<"rc_", _/binary>> } = Db) ->
case (catch check_is_admin(Db)) of
ok ->
ok;
_ ->
throw({unauthorized,
<<"You are not authorized to access this db.">>})
end;
check_is_member(#db{user_ctx=#user_ctx{name=Name,roles=Roles}=UserCtx}=Db) ->
case (catch check_is_admin(Db)) of
ok -> ok;
Expand Down
6 changes: 6 additions & 0 deletions apps/couch/src/couch_primary_sup.erl
Expand Up @@ -19,6 +19,12 @@ start_link() ->

init([]) ->
Children = [
{couch_uuids,
{couch_uuids, start_link, []},
permanent,
brutal_kill,
worker,
[couch_uuids]},
{couch_task_status,
{couch_task_status, start_link, []},
permanent,
Expand Down
13 changes: 12 additions & 1 deletion apps/couch/src/couch_server_sup.erl
Expand Up @@ -112,7 +112,18 @@ stop() ->

config_change("daemons", _) ->
supervisor:terminate_child(couch_server_sup, couch_secondary_services),
supervisor:restart_child(couch_server_sup, couch_secondary_services).
supervisor:restart_child(couch_server_sup,
couch_secondary_services);
config_change("stat", "rate") ->
NewRate = integer_to_list(
couch_config:get_value("stats", "rate", "1000")
),
couch_stats_aggregator:set_rate(NewRate);
config_change("stats", "samples") ->
SampleStr = couch_config:get("stats", "samples", "[0]"),
{ok, Samples} = couch_util:parse_term(SampleStr),
couch_stats_aggregator:set_samples(Samples).


init(ChildSpecs) ->
{ok, ChildSpecs}.
2 changes: 1 addition & 1 deletion apps/couch/src/couch_util.erl
Expand Up @@ -28,7 +28,7 @@
-export([url_strip_password/1]).
-export([encode_doc_id/1]).
-export([with_db/2]).
-export([start_app_deps/1]).
-export([start_app_deps/1, ensure_started/1]).
-export([capitalize/1]).
-export([json_decode/1]).
-export([get_uri/2, get_scheme/1, get_port/1]).
Expand Down
4 changes: 2 additions & 2 deletions apps/couch/src/couch_uuids.erl
Expand Up @@ -14,13 +14,13 @@

-behaviour(gen_server).

-export([start/0, stop/0]).
-export([start_link/0, stop/0]).
-export([new/0, random/0, utc_random/0]).

-export([init/1, terminate/2, code_change/3]).
-export([handle_call/3, handle_cast/2, handle_info/2]).

start() ->
start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).

stop() ->
Expand Down
2 changes: 0 additions & 2 deletions apps/couch/test/etap/001-load.t
Expand Up @@ -39,8 +39,6 @@ main(_) ->
couch_ref_counter,
couch_server,
couch_server_sup,
couch_stats_aggregator,
couch_stats_collector,
couch_stream,
couch_task_status,
couch_util,
Expand Down
2 changes: 1 addition & 1 deletion apps/couch/test/etap/041-uuid-gen.t
Expand Up @@ -26,7 +26,7 @@ utc_alg_config() ->
run_test(IniFiles, Test) ->
{ok, Pid} = couch_config:start_link(IniFiles),
erlang:monitor(process, Pid),
couch_uuids:start(),
couch_uuids:start_link(),
Test(),
couch_uuids:stop(),
couch_config:stop(),
Expand Down
2 changes: 1 addition & 1 deletion apps/couch_changes/src/couch_changes.erl
Expand Up @@ -12,9 +12,9 @@

-module(couch_changes).

-include("couch_changes.hrl").
-include_lib("couch/include/couch_db.hrl").
-include_lib("couch_httpd/include/couch_httpd.hrl").
-include_lib("couch_changes/include/couch_changes.hrl").
-include_lib("couch_mrview/include/couch_mrview.hrl").

-export([handle_changes/3]).
Expand Down
4 changes: 2 additions & 2 deletions apps/couch_changes/src/couch_httpd_changes.erl
Expand Up @@ -11,7 +11,7 @@
% the License.

-module(couch_httpd_changes).
-include_lib("couch_changes/include/couch_changes.hrl").
-include("couch_changes.hrl").
-include_lib("couch/include/couch_db.hrl").
-include_lib("couch_httpd/include/couch_httpd.hrl").
-export([handle_changes_req/2]).
Expand Down Expand Up @@ -101,7 +101,7 @@ do_changes_req(_Db, Req, #changes_args{feed="eventsource"}, ChangesFun,
{"Content-Type", "text/event-stream"},
{"Cache-Control", "no-cache"}
],
{ok, Resp} = couch_httpd:start_json_response(Req, 200, Headers),
{ok, Resp} = couch_httpd:start_chunked_response(Req, 200, Headers),
ChangesFun(MakeCallback(Resp));
do_changes_req(_Db, Req, _ChangesArgs, ChangesFun, MakeCallback) ->
% "longpoll" or "continuous"
Expand Down
12 changes: 11 additions & 1 deletion apps/couch_httpd/src/couch_httpd_misc_handlers.erl
Expand Up @@ -74,7 +74,17 @@ handle_utils_dir_req(Req, _) ->
send_method_not_allowed(Req, "GET,HEAD").

handle_all_dbs_req(#httpd{method='GET'}=Req) ->
{ok, DbNames} = couch_server:all_databases(),
IsAdmin = case catch(couch_httpd:verify_is_server_admin(Req)) of
ok -> true;
_ -> false
end,
{ok, DbNames} = couch_server:all_databases(fun
(<<"rc_", _/binary>>, Acc)
when IsAdmin =:= false ->
{ok, Acc};
(Dbname, Acc) ->
{ok, [Dbname|Acc]}
end, []),
send_json(Req, DbNames);
handle_all_dbs_req(Req) ->
send_method_not_allowed(Req, "GET,HEAD").
Expand Down
5 changes: 4 additions & 1 deletion apps/couch_httpd/src/couch_httpd_vhost.erl
Expand Up @@ -245,7 +245,10 @@ bind_path(_, _) ->

%% create vhost list from ini
make_vhosts() ->
Vhosts = lists:foldl(fun({Vhost, Path}, Acc) ->
Vhosts = lists:foldl(fun
({_, ""}, Acc) ->
Acc;
({Vhost, Path}, Acc) ->
[{parse_vhost(Vhost), split_path(Path)}|Acc]
end, [], couch_config:get("vhosts")),

Expand Down
5 changes: 1 addition & 4 deletions apps/couch_index/src/couch_index.app.src
Expand Up @@ -13,10 +13,7 @@
{application, couch_index, [
{description, "CouchDB Secondary Index Manager"},
{vsn, "0.1"},
{modules, [
couch_index,
couch_index_server
]},
{modules, []},
{registered, [couch_index_server]},
{applications, [kernel, stdlib, couch]},
{mod, {couch_index_app, []}}
Expand Down

0 comments on commit e942d68

Please sign in to comment.