Skip to content

Commit 6c256d5

Browse files
committed
chore(access): erlfmt
1 parent 732ae1d commit 6c256d5

19 files changed

Lines changed: 1224 additions & 735 deletions

src/chttpd/src/chttpd_db.erl

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ db_doc_req(#httpd{method = 'DELETE'} = Req, Db, DocId) ->
10471047
Rev ->
10481048
Body = {[{<<"_rev">>, ?l2b(Rev)}, {<<"_deleted">>, true}]}
10491049
end,
1050-
Doc = #doc{revs=Revs,body=Body,deleted=true,access=Doc0#doc.access},
1050+
Doc = #doc{revs = Revs, body = Body, deleted = true, access = Doc0#doc.access},
10511051
send_updated_doc(Req, Db, DocId, couch_doc_from_req(Req, Db, DocId, Doc));
10521052
db_doc_req(#httpd{method = 'GET', mochi_req = MochiReq} = Req, Db, DocId) ->
10531053
#doc_query_args{
@@ -1498,7 +1498,7 @@ receive_request_data(Req, LenLeft) when LenLeft > 0 ->
14981498
receive_request_data(_Req, _) ->
14991499
throw(<<"expected more data">>).
15001500

1501-
update_doc_result_to_json({#doc{id=Id,revs=Rev}, access}) ->
1501+
update_doc_result_to_json({#doc{id = Id, revs = Rev}, access}) ->
15021502
update_doc_result_to_json({{Id, Rev}, access});
15031503
update_doc_result_to_json({error, _} = Error) ->
15041504
{_Code, Err, Msg} = chttpd:error_info(Error),
@@ -2083,13 +2083,12 @@ parse_shards_opt("placement", Req, Default) ->
20832083
throw({bad_request, Err})
20842084
end
20852085
end;
2086-
2087-
20882086
parse_shards_opt("access", Req, Value) when is_list(Value) ->
20892087
parse_shards_opt("access", Req, list_to_existing_atom(Value));
20902088
parse_shards_opt("access", _Req, Value) when Value =:= true ->
20912089
case config:get_boolean("per_doc_access", "enabled", false) of
2092-
true -> true;
2090+
true ->
2091+
true;
20932092
false ->
20942093
Err = ?l2b(["The `access` option is not available on this CouchDB installation."]),
20952094
throw({bad_request, Err})
@@ -2099,7 +2098,6 @@ parse_shards_opt("access", _Req, Value) when Value =:= false ->
20992098
parse_shards_opt("access", _Req, _Value) ->
21002099
Err = ?l2b(["The `access` value should be a boolean."]),
21012100
throw({bad_request, Err});
2102-
21032101
parse_shards_opt(Param, Req, Default) ->
21042102
couch_log:error("~n parse_shards_opt Param: ~p, Default: ~p~n", [Param, Default]),
21052103
Val = chttpd:qs_value(Req, Param, Default),
@@ -2109,7 +2107,6 @@ parse_shards_opt(Param, Req, Default) ->
21092107
false -> throw({bad_request, Err})
21102108
end.
21112109

2112-
21132110
parse_engine_opt(Req) ->
21142111
case chttpd:qs_value(Req, "engine") of
21152112
undefined ->

src/chttpd/src/chttpd_view.erl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,20 @@ fabric_query_view(Db, Req, DDoc, ViewName, Args) ->
6969
Max = chttpd:chunked_response_buffer_size(),
7070
VAcc = #vacc{db = Db, req = Req, threshold = Max},
7171
Options = [{user_ctx, Req#httpd.user_ctx}],
72-
% {ok, Resp} = fabric:query_view(Db, Options, DDoc, ViewName,
73-
% fun view_cb/2, VAcc, Args),
74-
% {ok, Resp#vacc.resp}.
75-
% % TODO: This might just be a debugging leftover, we might be able
76-
% % to undo this by just returning {ok, Resp#vacc.resp}
77-
% % However, this *might* be here because we need to handle
78-
% % errors here now, because access might tell us to.
79-
% case fabric:query_view(Db, Options, DDoc, ViewName,
80-
% fun view_cb/2, VAcc, Args) of
81-
% {ok, Resp} ->
82-
% {ok, Resp#vacc.resp};
83-
% {error, Error} ->
84-
% throw(Error)
85-
% end.
72+
% {ok, Resp} = fabric:query_view(Db, Options, DDoc, ViewName,
73+
% fun view_cb/2, VAcc, Args),
74+
% {ok, Resp#vacc.resp}.
75+
% % TODO: This might just be a debugging leftover, we might be able
76+
% % to undo this by just returning {ok, Resp#vacc.resp}
77+
% % However, this *might* be here because we need to handle
78+
% % errors here now, because access might tell us to.
79+
% case fabric:query_view(Db, Options, DDoc, ViewName,
80+
% fun view_cb/2, VAcc, Args) of
81+
% {ok, Resp} ->
82+
% {ok, Resp#vacc.resp};
83+
% {error, Error} ->
84+
% throw(Error)
85+
% end.
8686

8787
{ok, Resp} = fabric:query_view(
8888
Db,

src/couch/src/couch_access_native_proc.erl

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
-module(couch_access_native_proc).
1414
-behavior(gen_server).
1515

16-
1716
-export([
1817
start_link/0,
1918
set_timeout/2,
@@ -29,71 +28,55 @@
2928
code_change/3
3029
]).
3130

32-
3331
-record(st, {
3432
indexes = [],
35-
timeout = 5000 % TODO: make configurable
33+
% TODO: make configurable
34+
timeout = 5000
3635
}).
3736

3837
start_link() ->
3938
gen_server:start_link(?MODULE, [], []).
4039

41-
4240
set_timeout(Pid, TimeOut) when is_integer(TimeOut), TimeOut > 0 ->
4341
gen_server:call(Pid, {set_timeout, TimeOut}).
4442

45-
4643
prompt(Pid, Data) ->
4744
gen_server:call(Pid, {prompt, Data}).
4845

49-
5046
init(_) ->
5147
{ok, #st{}}.
5248

53-
5449
terminate(_Reason, _St) ->
5550
ok.
5651

57-
5852
handle_call({set_timeout, TimeOut}, _From, St) ->
59-
{reply, ok, St#st{timeout=TimeOut}};
60-
53+
{reply, ok, St#st{timeout = TimeOut}};
6154
handle_call({prompt, [<<"reset">>]}, _From, St) ->
62-
{reply, true, St#st{indexes=[]}};
63-
55+
{reply, true, St#st{indexes = []}};
6456
handle_call({prompt, [<<"reset">>, _QueryConfig]}, _From, St) ->
65-
{reply, true, St#st{indexes=[]}};
66-
57+
{reply, true, St#st{indexes = []}};
6758
handle_call({prompt, [<<"add_fun">>, IndexInfo]}, _From, St) ->
6859
{reply, true, St};
69-
7060
handle_call({prompt, [<<"map_doc">>, Doc]}, _From, St) ->
7161
{reply, map_doc(St, mango_json:to_binary(Doc)), St};
72-
7362
handle_call({prompt, [<<"reduce">>, _, _]}, _From, St) ->
7463
{reply, null, St};
75-
7664
handle_call({prompt, [<<"rereduce">>, _, _]}, _From, St) ->
7765
{reply, null, St};
78-
7966
handle_call({prompt, [<<"index_doc">>, Doc]}, _From, St) ->
8067
{reply, [[]], St};
81-
8268
handle_call(Msg, _From, St) ->
8369
{stop, {invalid_call, Msg}, {invalid_call, Msg}, St}.
8470

8571
handle_cast(garbage_collect, St) ->
8672
erlang:garbage_collect(),
8773
{noreply, St};
88-
8974
handle_cast(Msg, St) ->
9075
{stop, {invalid_cast, Msg}, St}.
9176

92-
9377
handle_info(Msg, St) ->
9478
{stop, {invalid_info, Msg}, St}.
9579

96-
9780
code_change(_OldVsn, St, _Extra) ->
9881
{ok, St}.
9982

@@ -115,29 +98,42 @@ code_change(_OldVsn, St, _Extra) ->
11598
map_doc(_St, {Doc}) ->
11699
case couch_util:get_value(<<"_access">>, Doc) of
117100
undefined ->
118-
[[],[]]; % do not index this doc
101+
% do not index this doc
102+
[[], []];
119103
Access when is_list(Access) ->
120104
Id = couch_util:get_value(<<"_id">>, Doc),
121105
Rev = couch_util:get_value(<<"_rev">>, Doc),
122106
Seq = couch_util:get_value(<<"_seq">>, Doc),
123107
Deleted = couch_util:get_value(<<"_deleted">>, Doc, false),
124108
BodySp = couch_util:get_value(<<"_body_sp">>, Doc),
125109
% by-access-id
126-
ById = case Deleted of
127-
false ->
128-
lists:map(fun(UserOrRole) -> [
129-
[[UserOrRole, Id], Rev]
130-
] end, Access);
131-
_True -> [[]]
132-
end,
110+
ById =
111+
case Deleted of
112+
false ->
113+
lists:map(
114+
fun(UserOrRole) ->
115+
[
116+
[[UserOrRole, Id], Rev]
117+
]
118+
end,
119+
Access
120+
);
121+
_True ->
122+
[[]]
123+
end,
133124

134125
% by-access-seq
135-
BySeq = lists:map(fun(UserOrRole) -> [
136-
[[UserOrRole, Seq], [{rev, Rev}, {deleted, Deleted}, {body_sp, BodySp}]]
137-
] end, Access),
126+
BySeq = lists:map(
127+
fun(UserOrRole) ->
128+
[
129+
[[UserOrRole, Seq], [{rev, Rev}, {deleted, Deleted}, {body_sp, BodySp}]]
130+
]
131+
end,
132+
Access
133+
),
138134
ById ++ BySeq;
139135
Else ->
140136
% TODO: no comprende: should not be needed once we implement
141137
% _access field validation
142-
[[],[]]
138+
[[], []]
143139
end.

src/couch/src/couch_bt_engine.erl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,6 @@ id_tree_split(#full_doc_info{} = Info) ->
672672
id_tree_join(Id, {HighSeq, Deleted, DiskTree}) ->
673673
% Handle old formats before data_size was added
674674
id_tree_join(Id, {HighSeq, Deleted, #size_info{}, DiskTree});
675-
676675
id_tree_join(Id, {HighSeq, Deleted, Sizes, DiskTree}) ->
677676
id_tree_join(Id, {HighSeq, Deleted, Sizes, DiskTree, []});
678677
id_tree_join(Id, {HighSeq, Deleted, Sizes, DiskTree, Access}) ->

src/couch/src/couch_btree.erl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,11 @@ full_reduce_with_options(Bt, Options0) ->
116116
end,
117117
[UserName] = proplists:get_value(start_key, Options0, <<"">>),
118118
EndKey = {[UserName, {[]}]},
119-
Options = Options0 ++ [
120-
{end_key, EndKey}
121-
],
119+
Options =
120+
Options0 ++
121+
[
122+
{end_key, EndKey}
123+
],
122124
fold_reduce(Bt, CountFun, 0, Options).
123125

124126
size(#btree{root = nil}) ->

0 commit comments

Comments
 (0)