diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-05-04 17:42:37 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-05-04 17:42:37 +0900 |
commit | 28284c14973a59d5a7f0f8d2862da7f61b101640 (patch) | |
tree | d02e69af1e2992e578c17f4ca335987cb7fa0c03 /app/models | |
parent | 812dd06d512ab7774b375ce45aa9235aafc99911 (diff) | |
download | gitlab-ce-28284c14973a59d5a7f0f8d2862da7f61b101640.tar.gz |
Add validation and skip logic at #truncate
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/build_trace_chunk.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/app/models/ci/build_trace_chunk.rb b/app/models/ci/build_trace_chunk.rb index 870b4ae2033..08a4465821c 100644 --- a/app/models/ci/build_trace_chunk.rb +++ b/app/models/ci/build_trace_chunk.rb @@ -28,11 +28,14 @@ module Ci end def truncate(offset = 0) - self.append("", offset) if offset < size + raise ArgumentError, 'Offset is out of range' if offset > size || offset < 0 + return if offset == size # Skip the following process as it doesn't affect anything + + self.append("", offset) end def append(new_data, offset) - raise ArgumentError, 'Offset is out of range' if offset > data.bytesize || offset < 0 + raise ArgumentError, 'Offset is out of range' if offset > size || offset < 0 raise ArgumentError, 'Chunk size overflow' if CHUNK_SIZE < (offset + new_data.bytesize) set_data(data.byteslice(0, offset) + new_data) |