diff --git a/apps/emqx_management/src/emqx_mgmt_auth.erl b/apps/emqx_management/src/emqx_mgmt_auth.erl index a2b96fc1d..19aa48081 100644 --- a/apps/emqx_management/src/emqx_mgmt_auth.erl +++ b/apps/emqx_management/src/emqx_mgmt_auth.erl @@ -92,20 +92,22 @@ init_bootstrap_apps() -> end. need_bootstrap() -> - {atomic, Res} = mnesia:transaction(fun() -> bootstrap_apps() =:= [] end), + {atomic, Res} = mnesia:transaction( + fun() -> + Spec = [{#mqtt_app{id = '$1', desc = ?BOOTSTRAP_TAG, _ = '_'}, [], ['$1']}], + mnesia:select(mqtt_app, Spec, 1, read) =:= '$end_of_table' + end), Res. clear_bootstrap_apps() -> {atomic, ok} = mnesia:transaction(fun() -> + All = mnesia:match_object(mqtt_app, #mqtt_app{desc = ?BOOTSTRAP_TAG, _ = '_'}, read), DeleteFun = fun(A) -> mnesia:delete_object(A) end, - lists:foreach(DeleteFun, bootstrap_apps()) + lists:foreach(DeleteFun, All) end), ok. -bootstrap_apps() -> - mnesia:match_object(mqtt_app, #mqtt_app{desc = ?BOOTSTRAP_TAG, _ = '_'}, read). - init_bootstrap_apps(undefined) -> ok; init_bootstrap_apps(File) -> case file:open(File, [read, binary]) of