Speedup table setup, no io if EJABBERD_SCHEMA_PATH not set (#1461)

This commit is contained in:
Christophe Romain 2017-01-17 14:22:12 +01:00
parent c7476875e6
commit 2ce6d49a40
1 changed files with 9 additions and 13 deletions

View File

@ -117,19 +117,15 @@ merge(TabDef, CustomDef) ->
lists:ukeysort(1, CleanDef)).
parse(Module) ->
Path = case os:getenv("EJABBERD_SCHEMA_PATH") of
false ->
case code:priv_dir(ejabberd) of
{error, _} -> "schema"; % $SPOOL_DIR/schema
Priv -> filename:join(Priv, "schema")
end;
CustomDir ->
CustomDir
end,
File = filename:join(Path, atom_to_list(Module)++".mnesia"),
case file:consult(File) of
{ok, Terms} -> parse(Terms, []);
Error -> Error
case os:getenv("EJABBERD_SCHEMA_PATH") of
false ->
{error, undefined};
Path ->
File = filename:join(Path, atom_to_list(Module)++".mnesia"),
case file:consult(File) of
{ok, Terms} -> parse(Terms, []);
Error -> Error
end
end.
parse([], Acc) ->