%% @doc Format a user, by ensuring that all keys are atomized. format_user({struct, _} = Attributes) -> {struct, AttributeList} = atomize(Attributes), {struct, append_admin_status(AttributeList)}; format_user(Attributes) -> Attributes. %% @doc Given a proplist of attributes, add admin status. append_admin_status(Attributes) -> RiakCsAdminKey = riak_cs_control_configuration:cs_configuration( cs_admin_key), BinaryAdminKey = list_to_binary(RiakCsAdminKey), KeyId = proplists:get_value(key_id, Attributes), lists:append(Attributes, [{admin, KeyId =:= BinaryAdminKey}]). %% @doc Format an entire list of users. format_users(Users) -> [format_user(User) || User <- Users]. riak_cs_control/src/riak_cs_control_formatting.erl Friday, October 4, 13
%% @doc Return a context which determines if we serve %% up the application template or a file resource. identify_resource(ReqData, #context{resource=undefined}=Context) -> case wrq:disp_path(ReqData) of "" -> {true, Context#context{resource=template, filename=undefined}}; _ -> Tokens = wrq:path_tokens(ReqData), Filename = normalize_filepath(Tokens), {true, Context#context{resource=filename, filename=Filename}} end; identify_resource(_ReqData, Context) -> {true, Context}. riak_cs_control/src/riak_cs_control_wm_asset.erl Friday, October 4, 13
%% @doc If the file exists, allow it through, otherwise assume true if %% they are asking for the application template. resource_exists(ReqData, Context) -> case identify_resource(ReqData, Context) of {true, NewContext=#context{resource=template}} -> {true, ReqData, NewContext}; {true, NewContext=#context{resource=filename, filename=Filename}} -> case filelib:is_regular(Filename) of true -> {true, ReqData, NewContext}; _ -> {false, ReqData, NewContext} end end. riak_cs_control/src/riak_cs_control_wm_asset.erl Friday, October 4, 13
Checking whether the PLT /Users/cmeiklejohn/.dialyzer_plt is up-to- date... yes Proceeding with analysis... test.erl:13: Function check/0 has no local return test.erl:14: The call test:is_ok('ok') will never return since it differs in the 1st argument from the success typing arguments: ({'error',_} | {'ok',_}) done in 0m0.60s -module(test). -compile([export_all]). is_ok(Symbol) -> case Symbol of {ok, _} -> true; {error, _} -> false end. check() -> is_ok(ok). Friday, October 4, 13