diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-04-03 15:30:14 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-04-05 14:42:08 +0300 |
commit | d6b18d3946926cff5c6bd47b609a0d2e0c899317 (patch) | |
tree | c249aaf69daf6319118e70ae20f4975e8b13cb62 | |
parent | 9b7a0533ede133ad66d9ed0fba15d1b086e416dd (diff) |
Fix
-rw-r--r-- | app/controllers/projects/jobs_controller.rb | 32 | ||||
-rw-r--r-- | lib/gitlab/ci/trace/stream.rb | 2 |
2 files changed, 22 insertions, 12 deletions
diff --git a/app/controllers/projects/jobs_controller.rb b/app/controllers/projects/jobs_controller.rb index 5d6abcf906d..a604f623e49 100644 --- a/app/controllers/projects/jobs_controller.rb +++ b/app/controllers/projects/jobs_controller.rb @@ -119,17 +119,19 @@ class Projects::JobsController < Projects::ApplicationController end def raw - build.trace.read do |stream| - if trace_artifact_file - send_upload(trace_artifact_file, - send_params: { type: 'text/plain; charset=utf-8', disposition: 'inline' }, - redirect_params: { query: { 'response-content-type' => 'text/plain; charset=utf-8', 'response-content-disposition' => 'inline' } } ) - elsif stream.file? - send_file stream.path, type: 'text/plain; charset=utf-8', disposition: 'inline' - elsif build.old_trace - send_data stream.path, type: 'text/plain; charset=utf-8', disposition: 'inline', filename: 'job.log' - else - render_404 + if trace_artifact_file + send_upload(trace_artifact_file, + send_params: raw_send_params, + redirect_params: raw_redirect_params) + else + build.trace.read do |stream| + if stream.file? + send_file stream.path, type: 'text/plain; charset=utf-8', disposition: 'inline' + elsif build.old_trace + send_data stream.raw, type: 'text/plain; charset=utf-8', disposition: 'inline', filename: 'job.log' + else + render_404 + end end end end @@ -144,6 +146,14 @@ class Projects::JobsController < Projects::ApplicationController return access_denied! unless can?(current_user, :erase_build, build) end + def raw_send_params + { type: 'text/plain; charset=utf-8', disposition: 'inline' } + end + + def raw_redirect_params + { query: { 'response-content-type' => 'text/plain; charset=utf-8', 'response-content-disposition' => 'inline' } } + end + def trace_artifact_file @trace_artifact_file ||= build.job_artifacts_trace&.file end diff --git a/lib/gitlab/ci/trace/stream.rb b/lib/gitlab/ci/trace/stream.rb index ffb9ec61715..ca9f62ad80c 100644 --- a/lib/gitlab/ci/trace/stream.rb +++ b/lib/gitlab/ci/trace/stream.rb @@ -22,7 +22,7 @@ module Gitlab end def file? - self.path.present? if self.respond_to(:path) + self.path.present? if respond_to?(:path) end def limit(last_bytes = LIMIT_SIZE) |