Commit f5891ca0 authored by Shinya Maeda's avatar Shinya Maeda

Create EE::Projects::JobsController. Redirect raw as attachment

parent 7c49f3ea
class Projects::JobsController < Projects::ApplicationController class Projects::JobsController < Projects::ApplicationController
include SendFileUpload prepend EE::Projects::JobsController
before_action :build, except: [:index, :cancel_all] before_action :build, except: [:index, :cancel_all]
...@@ -119,24 +119,11 @@ class Projects::JobsController < Projects::ApplicationController ...@@ -119,24 +119,11 @@ class Projects::JobsController < Projects::ApplicationController
end end
def raw def raw
if trace_artifact build.trace.read do |stream|
send_upload(trace_artifact.file, if stream.file?
send_params: send_file stream.path, type: 'text/plain; charset=utf-8', disposition: 'inline'
{ else
type: 'text/plain; charset=utf-8', render_404
disposition: 'inline'
},
redirect_params:
{
query: { "response-content-disposition" => "inline" }
} )
else
build.trace.read do |stream|
if stream.file?
send_file stream.path, type: 'text/plain; charset=utf-8', disposition: 'inline'
else
render_404
end
end end
end end
end end
...@@ -159,8 +146,4 @@ class Projects::JobsController < Projects::ApplicationController ...@@ -159,8 +146,4 @@ class Projects::JobsController < Projects::ApplicationController
def build_path(build) def build_path(build)
project_job_path(build.project, build) project_job_path(build.project, build)
end end
def trace_artifact
build.job_artifacts_trace
end
end end
module EE
module Projects
module JobsController
extend ActiveSupport::Concern
include SendFileUpload
def raw
if trace_artifact_file
send_upload(trace_artifact_file,
send_params: raw_send_params,
redirect_params: raw_redirect_params)
else
super
end
end
private
def raw_send_params
{ type: 'text/plain; charset=utf-8', disposition: 'inline' }
end
def raw_redirect_params
{ query: { "response-content-disposition" => "attachment;filename=#{trace_artifact_file.filename}" } }
end
def trace_artifact_file
@trace_artifact_file ||= build.job_artifacts_trace&.file
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment