fix: there should not be multiple layers of directories when download trace zip file (#6165)
This commit is contained in:
parent
8c119ea6d9
commit
23e2bd62c5
|
@ -75,10 +75,10 @@ download_zip_log(#{name := Name}, _Param) ->
|
|||
TraceFiles = collect_trace_file(TraceLog),
|
||||
ZipDir = emqx_trace:zip_dir(),
|
||||
Zips = group_trace_file(ZipDir, TraceLog, TraceFiles),
|
||||
ZipFileName = ZipDir ++ TraceLog,
|
||||
ZipFileName = ZipDir ++ binary_to_list(Name) ++ ".zip",
|
||||
{ok, ZipFile} = zip:zip(ZipFileName, Zips, [{cwd, ZipDir}]),
|
||||
emqx_trace:delete_files_after_send(ZipFileName, Zips),
|
||||
{ok, #{}, {sendfile, 0, filelib:file_size(ZipFile), ZipFile}};
|
||||
{ok, ZipFile};
|
||||
{error, Reason} ->
|
||||
{error, Reason}
|
||||
end.
|
||||
|
|
|
@ -336,9 +336,8 @@ t_download_log(_Config) ->
|
|||
{ok, _} = emqtt:connect(Client),
|
||||
[begin _ = emqtt:ping(Client) end ||_ <- lists:seq(1, 5)],
|
||||
ct:sleep(100),
|
||||
{ok, #{}, {sendfile, 0, ZipFileSize, _ZipFile}} =
|
||||
emqx_trace_api:download_zip_log(#{name => Name}, []),
|
||||
?assert(ZipFileSize > 0),
|
||||
{ok, ZipFile} = emqx_trace_api:download_zip_log(#{name => Name}, []),
|
||||
?assert(filelib:file_size(ZipFile) > 0),
|
||||
ok = emqtt:disconnect(Client),
|
||||
unload(),
|
||||
ok.
|
||||
|
|
|
@ -87,7 +87,7 @@ update_trace(Path, Params) ->
|
|||
|
||||
download_zip_log(Path, Params) ->
|
||||
case emqx_trace_api:download_zip_log(Path, Params) of
|
||||
{ok, _Header, _File}= Return -> Return;
|
||||
{ok, File} -> minirest:return_file(File);
|
||||
{error, _Reason} = Err -> return(Err)
|
||||
end.
|
||||
|
||||
|
|
Loading…
Reference in New Issue