Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the unused check for required_files #3313

Merged
merged 1 commit into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/config/mongoose_config_parser.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
state_to_hosts/1,
state_to_host_types/1,
state_to_global_opt/3,
state_to_required_files/1,
can_override/2]).

%% config post-processing
Expand Down Expand Up @@ -143,12 +142,6 @@ state_to_global_opt(OptName, State, Default) ->
Opts = state_to_opts(State),
opts_to_global_opt(Opts, OptName, Default).

%% @doc Files, that are required to be present on disc.
-spec state_to_required_files(state()) -> list(file:filename()).
state_to_required_files(State) ->
Opts = state_to_opts(State),
opts_to_global_opt(Opts, required_files, []).

opts_to_global_opt([{config, OptName, OptValue}|_], OptName, _Default) ->
OptValue;
opts_to_global_opt([_|Opts], OptName, Default) ->
Expand Down
33 changes: 2 additions & 31 deletions src/ejabberd_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ get_config_path() ->
-spec load_file(File :: string()) -> ok.
load_file(File) ->
State = mongoose_config_parser:parse_file(File),
assert_required_files_exist(State),
set_opts(State).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down Expand Up @@ -277,23 +276,14 @@ get_categorized_options() ->
local_config => get_local_config(),
host_config => get_host_local_config()}.

%% @doc Returns configs on disc and in memory for this node.
%% This function prepares all state data to pass into pure code part
%% (i.e. mongoose_config_parser).
%% @doc Returns configs on disc and in memory for this node for inspection.
config_state() ->
ConfigFile = get_config_path(),
State = mongoose_config_parser:parse_file(ConfigFile),
%% Performance optimization hint:
%% terms_to_missing_and_required_files/1 actually parses Terms into State.
#{missing_files := MissingFiles,
required_files := RequiredFiles} =
state_to_missing_and_required_files(State),
#{mongoose_node => node(),
config_file => ConfigFile,
loaded_categorized_options => get_categorized_options(),
ondisc_config_state => State,
missing_files => MissingFiles,
required_files => RequiredFiles}.
ondisc_config_state => State}.

config_states() ->
config_states(all_cluster_nodes()).
Expand Down Expand Up @@ -322,22 +312,3 @@ other_cluster_nodes() ->
is_mongooseim_node(Node) ->
Apps = rpc:call(Node, application, which_applications, []),
lists:keymember(mongooseim, 1, Apps).

assert_required_files_exist(State) ->
RequiredFiles = mongoose_config_parser:state_to_required_files(State),
case missing_files(RequiredFiles) of
[] ->
ok;
MissingFiles ->
erlang:error(#{issue => missing_files,
filenames => MissingFiles})
end.

state_to_missing_and_required_files(State) ->
RequiredFiles = mongoose_config_parser:state_to_required_files(State),
MissingFiles = missing_files(RequiredFiles),
#{missing_files => MissingFiles, required_files => RequiredFiles}.

missing_files(RequiredFiles) ->
[Filename || Filename <- RequiredFiles,
not mongoose_config_utils:is_file_readable(Filename)].