summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/api/helpers/runner.rb1
-rw-r--r--lib/gitlab/ci/trace/chunked_io.rb10
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/api/helpers/runner.rb b/lib/api/helpers/runner.rb
index 382577cc931..35ac0b4cbca 100644
--- a/lib/api/helpers/runner.rb
+++ b/lib/api/helpers/runner.rb
@@ -52,7 +52,6 @@ module API
end
def job_token_valid?(job)
- # binding.pry
token = (params[JOB_TOKEN_PARAM] || env[JOB_TOKEN_HEADER]).to_s
token && job.valid_token?(token)
end
diff --git a/lib/gitlab/ci/trace/chunked_io.rb b/lib/gitlab/ci/trace/chunked_io.rb
index d768c011968..8dbe892df64 100644
--- a/lib/gitlab/ci/trace/chunked_io.rb
+++ b/lib/gitlab/ci/trace/chunked_io.rb
@@ -19,7 +19,7 @@ module Gitlab
@job = job
@chunks_cache = []
@tell = 0
- @size = job_chunks.last.try(&:end_offset).to_i
+ @size = calculate_size
yield self if block_given?
end
@@ -48,7 +48,7 @@ module Gitlab
-1
end
- raise 'new position is outside of file' if new_pos < 0 || new_pos > size
+ raise ArgumentError, 'new position is outside of file' if new_pos < 0 || new_pos > size
@tell = new_pos
end
@@ -135,7 +135,7 @@ module Gitlab
end
def truncate(offset)
- raise 'Outside of file' if offset > size
+ raise ArgumentError, 'Outside of file' if offset > size
@tell = offset
@size = offset
@@ -221,6 +221,10 @@ module Gitlab
def job_chunks
::Ci::JobTraceChunk.where(job: job)
end
+
+ def calculate_size
+ job_chunks.order(chunk_index: :desc).last.try(&:end_offset).to_i
+ end
end
end
end