Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
28284c14
Commit
28284c14
authored
May 04, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add validation and skip logic at #truncate
parent
812dd06d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
7 deletions
+6
-7
app/models/ci/build_trace_chunk.rb
app/models/ci/build_trace_chunk.rb
+5
-2
spec/models/ci/build_trace_chunk_spec.rb
spec/models/ci/build_trace_chunk_spec.rb
+1
-5
No files found.
app/models/ci/build_trace_chunk.rb
View file @
28284c14
...
...
@@ -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
.
byte
size
||
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
)
...
...
spec/models/ci/build_trace_chunk_spec.rb
View file @
28284c14
...
...
@@ -141,11 +141,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
context
'when offset is bigger than data size'
do
let
(
:offset
)
{
data
.
bytesize
+
1
}
it
do
expect_any_instance_of
(
described_class
).
not_to
receive
(
:append
)
{
}
subject
end
it
{
expect
{
subject
}.
to
raise_error
(
'Offset is out of range'
)
}
end
context
'when offset is 10'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment