BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
3bb68efb
Commit
3bb68efb
authored
Jan 05, 2018
by
Douwe Maan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'zj-blob-batch' into 'master'
Reroute batch blobs to single blob RPC See merge request gitlab-org/gitlab-ce!16082
parents
4dd0c55f
6b15784c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
17 deletions
+29
-17
blob.rb
lib/gitlab/git/blob.rb
+25
-6
blob_spec.rb
spec/lib/gitlab/git/blob_spec.rb
+4
-11
No files found.
lib/gitlab/git/blob.rb
View file @
3bb68efb
...
@@ -50,10 +50,19 @@ module Gitlab
...
@@ -50,10 +50,19 @@ module Gitlab
# to the caller to limit the number of blobs and blob_size_limit.
# to the caller to limit the number of blobs and blob_size_limit.
#
#
# Gitaly migration issue: https://gitlab.com/gitlab-org/gitaly/issues/798
# Gitaly migration issue: https://gitlab.com/gitlab-org/gitaly/issues/798
def
batch
(
repository
,
blob_references
,
blob_size_limit:
nil
)
def
batch
(
repository
,
blob_references
,
blob_size_limit:
MAX_DATA_DISPLAY_SIZE
)
blob_size_limit
||=
MAX_DATA_DISPLAY_SIZE
Gitlab
::
GitalyClient
.
migrate
(
:list_blobs_by_sha_path
)
do
|
is_enabled
|
blob_references
.
map
do
|
sha
,
path
|
if
is_enabled
find_by_rugged
(
repository
,
sha
,
path
,
limit:
blob_size_limit
)
Gitlab
::
GitalyClient
.
allow_n_plus_1_calls
do
blob_references
.
map
do
|
sha
,
path
|
find_by_gitaly
(
repository
,
sha
,
path
,
limit:
blob_size_limit
)
end
end
else
blob_references
.
map
do
|
sha
,
path
|
find_by_rugged
(
repository
,
sha
,
path
,
limit:
blob_size_limit
)
end
end
end
end
end
end
...
@@ -122,13 +131,23 @@ module Gitlab
...
@@ -122,13 +131,23 @@ module Gitlab
)
)
end
end
def
find_by_gitaly
(
repository
,
sha
,
path
)
def
find_by_gitaly
(
repository
,
sha
,
path
,
limit:
MAX_DATA_DISPLAY_SIZE
)
path
=
path
.
sub
(
/\A\/*/
,
''
)
path
=
path
.
sub
(
/\A\/*/
,
''
)
path
=
'/'
if
path
.
empty?
path
=
'/'
if
path
.
empty?
name
=
File
.
basename
(
path
)
name
=
File
.
basename
(
path
)
entry
=
Gitlab
::
GitalyClient
::
CommitService
.
new
(
repository
).
tree_entry
(
sha
,
path
,
MAX_DATA_DISPLAY_SIZE
)
# Gitaly will think that setting the limit to 0 means unlimited, while
# the client might only need the metadata and thus set the limit to 0.
# In this method we'll then set the limit to 1, but clear the byte of data
# that we got back so for the outside world it looks like the limit was
# actually 0.
req_limit
=
limit
==
0
?
1
:
limit
entry
=
Gitlab
::
GitalyClient
::
CommitService
.
new
(
repository
).
tree_entry
(
sha
,
path
,
req_limit
)
return
unless
entry
return
unless
entry
entry
.
data
=
""
if
limit
==
0
case
entry
.
type
case
entry
.
type
when
:COMMIT
when
:COMMIT
new
(
new
(
...
...
spec/lib/gitlab/git/blob_spec.rb
View file @
3bb68efb
...
@@ -202,16 +202,6 @@ describe Gitlab::Git::Blob, seed_helper: true do
...
@@ -202,16 +202,6 @@ describe Gitlab::Git::Blob, seed_helper: true do
context
'limiting'
do
context
'limiting'
do
subject
{
described_class
.
batch
(
repository
,
blob_references
,
blob_size_limit:
blob_size_limit
)
}
subject
{
described_class
.
batch
(
repository
,
blob_references
,
blob_size_limit:
blob_size_limit
)
}
context
'default'
do
let
(
:blob_size_limit
)
{
nil
}
it
'limits to MAX_DATA_DISPLAY_SIZE'
do
stub_const
(
'Gitlab::Git::Blob::MAX_DATA_DISPLAY_SIZE'
,
100
)
expect
(
subject
.
first
.
data
.
size
).
to
eq
(
100
)
end
end
context
'positive'
do
context
'positive'
do
let
(
:blob_size_limit
)
{
10
}
let
(
:blob_size_limit
)
{
10
}
...
@@ -221,7 +211,10 @@ describe Gitlab::Git::Blob, seed_helper: true do
...
@@ -221,7 +211,10 @@ describe Gitlab::Git::Blob, seed_helper: true do
context
'zero'
do
context
'zero'
do
let
(
:blob_size_limit
)
{
0
}
let
(
:blob_size_limit
)
{
0
}
it
{
expect
(
subject
.
first
.
data
).
to
eq
(
''
)
}
it
'only loads the metadata'
do
expect
(
subject
.
first
.
size
).
not_to
be
(
0
)
expect
(
subject
.
first
.
data
).
to
eq
(
''
)
end
end
end
context
'negative'
do
context
'negative'
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