summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Maczukin <tomasz@maczukin.pl>2016-04-19 15:48:16 +0200
committerTomasz Maczukin <tomasz@maczukin.pl>2016-04-19 23:32:48 +0200
commit94048fe07a85286ea007c807dfa1567e7f97bb4d (patch)
tree3fae0887ee68537ad13beb25d9f9e16d43cfd83f
parent239cc1ad57c7d2da4234d9bc7794ecf05358c1ed (diff)
downloadgitlab-ce-feature/incremental-build-trace-update.tar.gz
Fix Build#append_trace method usage when trace file doesn't exists yetfeature/incremental-build-trace-update
-rw-r--r--app/models/ci/build.rb2
-rw-r--r--lib/ci/api/builds.rb5
2 files changed, 4 insertions, 3 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 9ac6e7e1bfb..d42a65620ff 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -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
diff --git a/lib/ci/api/builds.rb b/lib/ci/api/builds.rb
index 08a2b006a5f..607359769d1 100644
--- a/lib/ci/api/builds.rb
+++ b/lib/ci/api/builds.rb
@@ -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)