diff options
Diffstat (limited to 'lib/gitlab/ci/trace/checksum.rb')
-rw-r--r-- | lib/gitlab/ci/trace/checksum.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/gitlab/ci/trace/checksum.rb b/lib/gitlab/ci/trace/checksum.rb index 62532ef1cd2..7cdb6a6c03c 100644 --- a/lib/gitlab/ci/trace/checksum.rb +++ b/lib/gitlab/ci/trace/checksum.rb @@ -64,10 +64,33 @@ module Gitlab end end + def state_bytesize + strong_memoize(:state_bytesize) do + build.pending_state&.trace_bytesize + end + end + + def trace_size + strong_memoize(:trace_size) do + trace_chunks.sum { |chunk| chunk_size(chunk) } + end + end + + def corrupted? + return false unless has_bytesize? + return false if valid? + + state_bytesize.to_i != trace_size.to_i + end + def chunks_count trace_chunks.to_a.size end + def has_bytesize? + state_bytesize.present? + end + private def chunk_size(chunk) |