summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-03-30 18:16:09 +0900
committerShinya Maeda <shinya@gitlab.com>2018-04-03 21:09:51 +0900
commit92434d00bf1b0d8aa231d2d8f233fe45899cc5a4 (patch)
tree8363fd1d965cd2c4d6eff3f020260b80ab2ccb9d
parent4a9d9f15eff0b57c2648679d93dece192c90c904 (diff)
downloadgitlab-ce-92434d00bf1b0d8aa231d2d8f233fe45899cc5a4.tar.gz
Fix database trace to read raw
-rw-r--r--app/controllers/projects/jobs_controller.rb30
-rw-r--r--lib/gitlab/ci/trace/stream.rb2
2 files changed, 12 insertions, 20 deletions
diff --git a/app/controllers/projects/jobs_controller.rb b/app/controllers/projects/jobs_controller.rb
index 85e972d9731..5d6abcf906d 100644
--- a/app/controllers/projects/jobs_controller.rb
+++ b/app/controllers/projects/jobs_controller.rb
@@ -119,17 +119,17 @@ class Projects::JobsController < Projects::ApplicationController
end
def raw
- 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'
- else
- render_404
- end
+ 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
end
end
end
@@ -144,14 +144,6 @@ 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 b3fe3ef1c4d..ffb9ec61715 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?
+ self.path.present? if self.respond_to(:path)
end
def limit(last_bytes = LIMIT_SIZE)