summaryrefslogtreecommitdiff
path: root/app/controllers/projects
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/projects')
-rw-r--r--app/controllers/projects/jobs_controller.rb30
1 files changed, 17 insertions, 13 deletions
diff --git a/app/controllers/projects/jobs_controller.rb b/app/controllers/projects/jobs_controller.rb
index 900ebc61856..d2703f5cc38 100644
--- a/app/controllers/projects/jobs_controller.rb
+++ b/app/controllers/projects/jobs_controller.rb
@@ -49,21 +49,25 @@ class Projects::JobsController < Projects::ApplicationController
# rubocop: enable CodeReuse/ActiveRecord
def trace
- @build.trace.read do |stream|
- respond_to do |format|
- format.json do
- @build.trace.being_watched!
-
- build_trace = Ci::BuildTrace.new(
- build: @build,
- stream: stream,
- state: params[:state])
-
- render json: BuildTraceSerializer
- .new(project: @project, current_user: @current_user)
- .represent(build_trace)
+ @build.trace.being_watched! if @build.running?
+
+ if @build.has_trace?
+ @build.trace.read do |stream|
+ respond_to do |format|
+ format.json do
+ build_trace = Ci::BuildTrace.new(
+ build: @build,
+ stream: stream,
+ state: params[:state])
+
+ render json: BuildTraceSerializer
+ .new(project: @project, current_user: @current_user)
+ .represent(build_trace)
+ end
end
end
+ else
+ head :no_content
end
end