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
Boxiang Sun
gitlab-ce
Commits
a689a220
Commit
a689a220
authored
Apr 02, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix static analysys
parent
1de5b8db
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
24 deletions
+18
-24
lib/gitlab/ci/trace/chunked_file/chunk_store/redis.rb
lib/gitlab/ci/trace/chunked_file/chunk_store/redis.rb
+4
-4
lib/gitlab/ci/trace/chunked_file/chunked_io.rb
lib/gitlab/ci/trace/chunked_file/chunked_io.rb
+3
-3
lib/gitlab/ci/trace/chunked_file/concerns/callbacks.rb
lib/gitlab/ci/trace/chunked_file/concerns/callbacks.rb
+7
-8
lib/gitlab/ci/trace/chunked_file/concerns/errors.rb
lib/gitlab/ci/trace/chunked_file/concerns/errors.rb
+0
-1
lib/gitlab/ci/trace/chunked_file/concerns/permissions.rb
lib/gitlab/ci/trace/chunked_file/concerns/permissions.rb
+3
-5
spec/factories/ci/job_trace_chunks.rb
spec/factories/ci/job_trace_chunks.rb
+1
-3
No files found.
lib/gitlab/ci/trace/chunked_file/chunk_store/redis.rb
View file @
a689a220
...
...
@@ -24,7 +24,7 @@ module Gitlab
def
chunks_count
(
job_id
)
Gitlab
::
Redis
::
Cache
.
with
do
|
redis
|
redis
.
scan_each
(
:match
=>
buffer_key
(
job_id
,
'?'
)).
inject
(
0
)
do
|
sum
,
key
|
redis
.
scan_each
(
match:
buffer_key
(
job_id
,
'?'
)).
inject
(
0
)
do
|
sum
,
key
|
sum
+
1
end
end
...
...
@@ -32,15 +32,15 @@ module Gitlab
def
chunks_size
(
job_id
)
Gitlab
::
Redis
::
Cache
.
with
do
|
redis
|
redis
.
scan_each
(
:match
=>
buffer_key
(
job_id
,
'?'
)).
inject
(
0
)
do
|
sum
,
key
|
sum
+
=
redis
.
strlen
(
key
)
redis
.
scan_each
(
match:
buffer_key
(
job_id
,
'?'
)).
inject
(
0
)
do
|
sum
,
key
|
sum
+
redis
.
strlen
(
key
)
end
end
end
def
delete_all
(
job_id
)
Gitlab
::
Redis
::
Cache
.
with
do
|
redis
|
redis
.
scan_each
(
:match
=>
buffer_key
(
job_id
,
'?'
))
do
|
key
|
redis
.
scan_each
(
match:
buffer_key
(
job_id
,
'?'
))
do
|
key
|
redis
.
del
(
key
)
end
end
...
...
lib/gitlab/ci/trace/chunked_file/chunked_io.rb
View file @
a689a220
...
...
@@ -189,10 +189,10 @@ module Gitlab
chunk_store
.
open
(
job_id
,
chunk_index
,
params_for_store
)
do
|
store
|
with_callbacks
(
:write_chunk
,
store
)
do
written_size
=
if
buffer_size
==
data
.
length
||
store
.
size
==
0
store
.
write!
(
data
)
else
written_size
=
if
store
.
size
>
0
# # rubocop:disable ZeroLengthPredicate
store
.
append!
(
data
)
else
store
.
write!
(
data
)
end
raise
WriteError
,
'Written size mismatch'
unless
data
.
length
==
written_size
...
...
lib/gitlab/ci/trace/chunked_file/concerns/callbacks.rb
View file @
a689a220
...
...
@@ -7,27 +7,26 @@ module Gitlab
extend
ActiveSupport
::
Concern
included
do
class_attribute
:_before_callbacks
,
:_after_callbacks
,
:instance_writer
=>
false
class_attribute
:_before_callbacks
,
:_after_callbacks
,
instance_writer:
false
self
.
_before_callbacks
=
Hash
.
new
[]
self
.
_after_callbacks
=
Hash
.
new
[]
end
def
with_callbacks
(
kind
,
*
args
)
self
.
class
.
_before_callbacks
[
kind
].
each
{
|
c
|
send
c
,
*
args
}
self
.
class
.
_before_callbacks
[
kind
].
each
{
|
c
|
send
c
,
*
args
}
# rubocop:disable GitlabSecurity/PublicSend
yield
self
.
class
.
_after_callbacks
[
kind
].
each
{
|
c
|
send
c
,
*
args
}
self
.
class
.
_after_callbacks
[
kind
].
each
{
|
c
|
send
c
,
*
args
}
# rubocop:disable GitlabSecurity/PublicSend
end
module
ClassMethods
def
before_callback
(
kind
,
callback
)
self
.
_before_callbacks
=
self
.
_before_callbacks
.
merge
kind
=>
_before_callbacks
[
kind
]
+
[
callback
]
self
.
_before_callbacks
=
self
.
_before_callbacks
.
merge
kind
=>
_before_callbacks
[
kind
]
+
[
callback
]
end
def
after_callback
(
kind
,
callback
)
self
.
_after_callbacks
=
self
.
_after_callbacks
.
merge
kind
=>
_after_callbacks
[
kind
]
+
[
callback
]
self
.
_after_callbacks
=
self
.
_after_callbacks
.
merge
kind
=>
_after_callbacks
[
kind
]
+
[
callback
]
end
end
end
...
...
lib/gitlab/ci/trace/chunked_file/concerns/errors.rb
View file @
a689a220
...
...
@@ -8,7 +8,6 @@ module Gitlab
included
do
WriteError
=
Class
.
new
(
StandardError
)
FailedToGetChunkError
=
Class
.
new
(
StandardError
)
end
end
end
...
...
lib/gitlab/ci/trace/chunked_file/concerns/permissions.rb
View file @
a689a220
...
...
@@ -6,12 +6,10 @@ module Gitlab
module
Permissions
extend
ActiveSupport
::
Concern
WRITABLE_MODE
=
%w[a]
READABLE_MODE
=
%w[r +]
WRITABLE_MODE
=
%w[a]
.
freeze
READABLE_MODE
=
%w[r +]
.
freeze
included
do
PermissionError
=
Class
.
new
(
StandardError
)
attr_reader
:write_lock_uuid
end
...
...
@@ -20,7 +18,7 @@ module Gitlab
@write_lock_uuid
=
Gitlab
::
ExclusiveLease
.
new
(
write_lock_key
(
job_id
),
timeout:
1
.
hour
.
to_i
).
try_obtain
raise
Permission
Error
,
'Already opened by another process'
unless
write_lock_uuid
raise
IO
Error
,
'Already opened by another process'
unless
write_lock_uuid
end
super
...
...
spec/factories/ci/job_trace_chunks.rb
View file @
a689a220
include
ActionDispatch
::
TestProcess
FactoryBot
.
define
do
factory
:job_trace_chunk
,
class:
Ci
::
JobTraceChunk
do
factory
:
ci_
job_trace_chunk
,
class:
Ci
::
JobTraceChunk
do
job
factory: :ci_build
end
end
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