chore(emqx_conf): extract data dirs to sync to a macro

This commit is contained in:
Ivan Dyachkov 2024-04-30 11:22:49 +02:00
parent 3386f565aa
commit 035b8480b0
1 changed files with 5 additions and 3 deletions

View File

@ -81,11 +81,13 @@ get_override_config_file() ->
end
end.
-define(DATA_DIRS, ["authz", "certs"]).
sync_data_from_node() ->
Dir = emqx:data_dir(),
TargetDirs = lists:filter(fun(Type) -> filelib:is_dir(filename:join(Dir, Type)) end, [
"authz", "certs"
]),
TargetDirs = lists:filter(
fun(Type) -> filelib:is_dir(filename:join(Dir, Type)) end, ?DATA_DIRS
),
Name = "data.zip",
case zip:zip(Name, TargetDirs, [memory, {cwd, Dir}]) of
{ok, {Name, Bin}} -> {ok, Bin};