Fix Build#append_trace method usage when trace file doesn't exists yet

This commit is contained in:
Tomasz Maczukin 2016-04-19 15:48:16 +02:00
parent 4019b0d872
commit a84d0204bf
No known key found for this signature in database
GPG key ID: 7E9EB2E4B0F625CD
2 changed files with 4 additions and 3 deletions

View file

@ -253,7 +253,7 @@ module Ci
def append_trace(trace_part, offset)
recreate_trace_dir
File.truncate(path_to_trace, offset)
File.truncate(path_to_trace, offset) if File.exist?(path_to_trace)
File.open(path_to_trace, 'a') do |f|
f.write(trace_part)
end

View file

@ -71,8 +71,9 @@ module Ci
content_range = request.headers['Content-Range']
content_range = content_range.split('-')
unless build.trace_length == content_range[0].to_i
return error!('416 Range Not Satisfiable', 416, { 'Range' => "0-#{build.trace_length}" })
current_length = build.trace_length
unless current_length == content_range[0].to_i
return error!('416 Range Not Satisfiable', 416, { 'Range' => "0-#{current_length}" })
end
build.append_trace(request.body.read, content_range[0].to_i)