修复: 代码溯源pdf只需下载一次

This commit is contained in:
yystopf 2022-07-21 10:52:21 +08:00
parent 88fb11ea92
commit abac8b9c46
1 changed files with 11 additions and 5 deletions

View File

@ -69,12 +69,18 @@ class Traces::ProjectsController < Traces::BaseController
def task_pdf
return render_error("task_id错误") if params[:task_id].blank?
result = Trace::PdfReportService.call(current_user.trace_token, params[:task_id])
if result.is_a?(Hash) && result[:code] == 200
redirect_to result[:download_url]
task_id = params[:task_id]
return render_error("task_id错误") if task_id.blank?
file_save_path = "public/trace_task_results/#{task_id}/report.pdf"
if File.exists?(file_save_path)
redirect_to "/trace_task_results/#{task_id}/report.pdf"
else
render_error("下载报告失败!")
result = Trace::PdfReportService.call(current_user.trace_token, task_id)
if result.is_a?(Hash) && result[:code] == 200
redirect_to result[:download_url]
else
render_error("下载报告失败!")
end
end
rescue Exception => exception
puts exception.message