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
...
@@ -24,7 +24,7 @@ module Gitlab
def
chunks_count
(
job_id
)
def
chunks_count
(
job_id
)
Gitlab
::
Redis
::
Cache
.
with
do
|
redis
|
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
sum
+
1
end
end
end
end
...
@@ -32,15 +32,15 @@ module Gitlab
...
@@ -32,15 +32,15 @@ module Gitlab
def
chunks_size
(
job_id
)
def
chunks_size
(
job_id
)
Gitlab
::
Redis
::
Cache
.
with
do
|
redis
|
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
+
=
redis
.
strlen
(
key
)
sum
+
redis
.
strlen
(
key
)
end
end
end
end
end
end
def
delete_all
(
job_id
)
def
delete_all
(
job_id
)
Gitlab
::
Redis
::
Cache
.
with
do
|
redis
|
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
)
redis
.
del
(
key
)
end
end
end
end
...
...
lib/gitlab/ci/trace/chunked_file/chunked_io.rb
View file @
a689a220
...
@@ -189,10 +189,10 @@ module Gitlab
...
@@ -189,10 +189,10 @@ module Gitlab
chunk_store
.
open
(
job_id
,
chunk_index
,
params_for_store
)
do
|
store
|
chunk_store
.
open
(
job_id
,
chunk_index
,
params_for_store
)
do
|
store
|
with_callbacks
(
:write_chunk
,
store
)
do
with_callbacks
(
:write_chunk
,
store
)
do
written_size
=
if
buffer_size
==
data
.
length
||
store
.
size
==
0
written_size
=
if
store
.
size
>
0
# # rubocop:disable ZeroLengthPredicate
store
.
write!
(
data
)
else
store
.
append!
(
data
)
store
.
append!
(
data
)
else
store
.
write!
(
data
)
end
end
raise
WriteError
,
'Written size mismatch'
unless
data
.
length
==
written_size
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
...
@@ -7,27 +7,26 @@ module Gitlab
extend
ActiveSupport
::
Concern
extend
ActiveSupport
::
Concern
included
do
included
do
class_attribute
:_before_callbacks
,
:_after_callbacks
,
class_attribute
:_before_callbacks
,
:_after_callbacks
,
instance_writer:
false
:instance_writer
=>
false
self
.
_before_callbacks
=
Hash
.
new
[]
self
.
_before_callbacks
=
Hash
.
new
[]
self
.
_after_callbacks
=
Hash
.
new
[]
self
.
_after_callbacks
=
Hash
.
new
[]
end
end
def
with_callbacks
(
kind
,
*
args
)
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
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
end
module
ClassMethods
module
ClassMethods
def
before_callback
(
kind
,
callback
)
def
before_callback
(
kind
,
callback
)
self
.
_before_callbacks
=
self
.
_before_callbacks
.
self
.
_before_callbacks
=
self
.
_before_callbacks
merge
kind
=>
_before_callbacks
[
kind
]
+
[
callback
]
.
merge
kind
=>
_before_callbacks
[
kind
]
+
[
callback
]
end
end
def
after_callback
(
kind
,
callback
)
def
after_callback
(
kind
,
callback
)
self
.
_after_callbacks
=
self
.
_after_callbacks
.
self
.
_after_callbacks
=
self
.
_after_callbacks
merge
kind
=>
_after_callbacks
[
kind
]
+
[
callback
]
.
merge
kind
=>
_after_callbacks
[
kind
]
+
[
callback
]
end
end
end
end
end
end
...
...
lib/gitlab/ci/trace/chunked_file/concerns/errors.rb
View file @
a689a220
...
@@ -8,7 +8,6 @@ module Gitlab
...
@@ -8,7 +8,6 @@ module Gitlab
included
do
included
do
WriteError
=
Class
.
new
(
StandardError
)
WriteError
=
Class
.
new
(
StandardError
)
FailedToGetChunkError
=
Class
.
new
(
StandardError
)
end
end
end
end
end
end
...
...
lib/gitlab/ci/trace/chunked_file/concerns/permissions.rb
View file @
a689a220
...
@@ -6,12 +6,10 @@ module Gitlab
...
@@ -6,12 +6,10 @@ module Gitlab
module
Permissions
module
Permissions
extend
ActiveSupport
::
Concern
extend
ActiveSupport
::
Concern
WRITABLE_MODE
=
%w[a]
WRITABLE_MODE
=
%w[a]
.
freeze
READABLE_MODE
=
%w[r +]
READABLE_MODE
=
%w[r +]
.
freeze
included
do
included
do
PermissionError
=
Class
.
new
(
StandardError
)
attr_reader
:write_lock_uuid
attr_reader
:write_lock_uuid
end
end
...
@@ -20,7 +18,7 @@ module Gitlab
...
@@ -20,7 +18,7 @@ module Gitlab
@write_lock_uuid
=
Gitlab
::
ExclusiveLease
@write_lock_uuid
=
Gitlab
::
ExclusiveLease
.
new
(
write_lock_key
(
job_id
),
timeout:
1
.
hour
.
to_i
).
try_obtain
.
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
end
super
super
...
...
spec/factories/ci/job_trace_chunks.rb
View file @
a689a220
include
ActionDispatch
::
TestProcess
FactoryBot
.
define
do
FactoryBot
.
define
do
factory
:job_trace_chunk
,
class:
Ci
::
JobTraceChunk
do
factory
:
ci_
job_trace_chunk
,
class:
Ci
::
JobTraceChunk
do
job
factory: :ci_build
job
factory: :ci_build
end
end
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