fix: clean trace zip file after download
This commit is contained in:
parent
98b1a232e1
commit
773c464572
|
@ -1,6 +1,6 @@
|
||||||
{application, emqx_plugin_libs,
|
{application, emqx_plugin_libs,
|
||||||
[{description, "EMQ X Plugin utility libs"},
|
[{description, "EMQ X Plugin utility libs"},
|
||||||
{vsn, "4.4.3"},
|
{vsn, "4.4.4"},
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{applications, [kernel,stdlib]},
|
{applications, [kernel,stdlib]},
|
||||||
{env, []}
|
{env, []}
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
%% -*- mode: erlang -*-
|
%% -*- mode: erlang -*-
|
||||||
%% Unless you know what you are doing, DO NOT edit manually!!
|
%% Unless you know what you are doing, DO NOT edit manually!!
|
||||||
{VSN,
|
{VSN,
|
||||||
[{"4.4.2",[{load_module,emqx_plugin_libs_ssl,brutal_purge,soft_purge,[]}]},
|
[
|
||||||
|
{"4.4.3",
|
||||||
|
[{load_module,emqx_trace,brutal_purge,soft_purge,[]},
|
||||||
|
{load_module,emqx_trace_api,brutal_purge,soft_purge,[]}]},
|
||||||
|
{"4.4.2",[{load_module,emqx_plugin_libs_ssl,brutal_purge,soft_purge,[]}]},
|
||||||
{"4.4.1",
|
{"4.4.1",
|
||||||
[{load_module,emqx_plugin_libs_ssl,brutal_purge,soft_purge,[]},
|
[{load_module,emqx_plugin_libs_ssl,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_trace,brutal_purge,soft_purge,[]},
|
{load_module,emqx_trace,brutal_purge,soft_purge,[]},
|
||||||
|
@ -13,7 +17,11 @@
|
||||||
{update,emqx_slow_subs,{advanced,["4.4.0"]}},
|
{update,emqx_slow_subs,{advanced,["4.4.0"]}},
|
||||||
{load_module,emqx_slow_subs_api,brutal_purge,soft_purge,[]}]},
|
{load_module,emqx_slow_subs_api,brutal_purge,soft_purge,[]}]},
|
||||||
{<<".*">>,[]}],
|
{<<".*">>,[]}],
|
||||||
[{"4.4.2",[{load_module,emqx_plugin_libs_ssl,brutal_purge,soft_purge,[]}]},
|
[
|
||||||
|
{"4.4.3",
|
||||||
|
[{load_module,emqx_trace,brutal_purge,soft_purge,[]},
|
||||||
|
{load_module,emqx_trace_api,brutal_purge,soft_purge,[]}]},
|
||||||
|
{"4.4.2",[{load_module,emqx_plugin_libs_ssl,brutal_purge,soft_purge,[]}]},
|
||||||
{"4.4.1",
|
{"4.4.1",
|
||||||
[{load_module,emqx_plugin_libs_ssl,brutal_purge,soft_purge,[]},
|
[{load_module,emqx_plugin_libs_ssl,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_trace,brutal_purge,soft_purge,[]},
|
{load_module,emqx_trace,brutal_purge,soft_purge,[]},
|
||||||
|
|
|
@ -226,7 +226,8 @@ handle_info({'DOWN', _Ref, process, Pid, _Reason}, State = #{monitors := Monitor
|
||||||
case maps:take(Pid, Monitors) of
|
case maps:take(Pid, Monitors) of
|
||||||
error -> {noreply, State};
|
error -> {noreply, State};
|
||||||
{Files, NewMonitors} ->
|
{Files, NewMonitors} ->
|
||||||
lists:foreach(fun file:delete/1, Files),
|
ZipDir = emqx_trace:zip_dir(),
|
||||||
|
lists:foreach(fun(F) -> file:delete(filename:join([ZipDir, F])) end, Files),
|
||||||
{noreply, State#{monitors => NewMonitors}}
|
{noreply, State#{monitors => NewMonitors}}
|
||||||
end;
|
end;
|
||||||
handle_info({timeout, TRef, update_trace},
|
handle_info({timeout, TRef, update_trace},
|
||||||
|
@ -403,7 +404,7 @@ fill_default(Trace = #?TRACE{end_at = undefined, start_at = StartAt}) ->
|
||||||
fill_default(Trace#?TRACE{end_at = StartAt + 10 * 60});
|
fill_default(Trace#?TRACE{end_at = StartAt + 10 * 60});
|
||||||
fill_default(Trace) -> Trace.
|
fill_default(Trace) -> Trace.
|
||||||
|
|
||||||
-define(NAME_RE, "^[A-Za-z]+[A-Za-z0-9-_]*$").
|
-define(NAME_RE, "^[0-9A-Za-z]+[A-Za-z0-9-_]*$").
|
||||||
|
|
||||||
to_trace(#{name := Name} = Trace, Rec) ->
|
to_trace(#{name := Name} = Trace, Rec) ->
|
||||||
case re:run(Name, ?NAME_RE) of
|
case re:run(Name, ?NAME_RE) of
|
||||||
|
|
|
@ -97,9 +97,9 @@ download_zip_log(#{name := Name}, _Param) ->
|
||||||
ZipDir = emqx_trace:zip_dir(),
|
ZipDir = emqx_trace:zip_dir(),
|
||||||
Zips = group_trace_file(ZipDir, TraceLog, TraceFiles),
|
Zips = group_trace_file(ZipDir, TraceLog, TraceFiles),
|
||||||
ZipFileName0 = binary_to_list(Name) ++ ".zip",
|
ZipFileName0 = binary_to_list(Name) ++ ".zip",
|
||||||
ZipFileName = filename:join([Zips, ZipFileName0]),
|
ZipFileName = filename:join([ZipDir, ZipFileName0]),
|
||||||
{ok, ZipFile} = zip:zip(ZipFileName, Zips, [{cwd, ZipDir}]),
|
{ok, ZipFile} = zip:zip(ZipFileName, Zips, [{cwd, ZipDir}]),
|
||||||
emqx_trace:delete_files_after_send(ZipFileName, Zips),
|
emqx_trace:delete_files_after_send(ZipFileName0, Zips),
|
||||||
{ok, ZipFile};
|
{ok, ZipFile};
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
{error, Reason}
|
{error, Reason}
|
||||||
|
|
Loading…
Reference in New Issue