fix(emqx_management): ensure trace file dir is deleted on zip exception
This commit is contained in:
parent
2cf297029d
commit
42182279b7
|
@ -471,10 +471,15 @@ download_trace_log(get, #{bindings := #{name := Name}, query_string := Query}) -
|
||||||
%% Write files to ZipDir and create an in-memory zip file
|
%% Write files to ZipDir and create an in-memory zip file
|
||||||
Zips = group_trace_file(ZipDir, TraceLog, TraceFiles),
|
Zips = group_trace_file(ZipDir, TraceLog, TraceFiles),
|
||||||
ZipName = binary_to_list(Name) ++ ".zip",
|
ZipName = binary_to_list(Name) ++ ".zip",
|
||||||
{ok, {ZipName, Binary}} = zip:zip(ZipName, Zips, [memory, {cwd, ZipDir}]),
|
Binary =
|
||||||
%% emqx_trace:delete_files_after_send(ZipFileName, Zips),
|
try
|
||||||
%% TODO use file replace file_binary.(delete file after send is not ready now).
|
{ok, {ZipName, Bin}} = zip:zip(ZipName, Zips, [memory, {cwd, ZipDir}]),
|
||||||
ok = file:del_dir_r(ZipDir),
|
Bin
|
||||||
|
after
|
||||||
|
%% emqx_trace:delete_files_after_send(ZipFileName, Zips),
|
||||||
|
%% TODO use file replace file_binary.(delete file after send is not ready now).
|
||||||
|
ok = file:del_dir_r(ZipDir)
|
||||||
|
end,
|
||||||
?tp(trace_api_download_trace_log, #{
|
?tp(trace_api_download_trace_log, #{
|
||||||
files => Zips,
|
files => Zips,
|
||||||
name => Name,
|
name => Name,
|
||||||
|
|
Loading…
Reference in New Issue