]> granicus.if.org Git - ejabberd/commitdiff
Speedup table setup, no io if EJABBERD_SCHEMA_PATH not set (#1461)
authorChristophe Romain <christophe.romain@process-one.net>
Tue, 17 Jan 2017 13:22:12 +0000 (14:22 +0100)
committerChristophe Romain <christophe.romain@process-one.net>
Tue, 17 Jan 2017 13:22:12 +0000 (14:22 +0100)
src/ejabberd_mnesia.erl

index 4da5608e1cd1081fe0872fc4afa72852d77889b1..63f6b1defe11bb897476ef812c84e946999ab5cc 100644 (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) ->