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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
4223a6fe
Commit
4223a6fe
authored
Jul 12, 2018
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor uploads manager to grab uploads in batches
parent
8ea2027f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
lib/gitlab/import_export/uploads_manager.rb
lib/gitlab/import_export/uploads_manager.rb
+16
-6
No files found.
lib/gitlab/import_export/uploads_manager.rb
View file @
4223a6fe
...
...
@@ -3,6 +3,8 @@ module Gitlab
class
UploadsManager
include
Gitlab
::
ImportExport
::
CommandLineUtil
UPLOADS_BATCH_SIZE
=
100
def
initialize
(
project
:,
shared
:,
relative_export_path:
'uploads'
,
from:
nil
)
@project
=
project
@shared
=
shared
...
...
@@ -54,7 +56,7 @@ module Gitlab
def
copy_from_object_storage
return
unless
Gitlab
::
ImportExport
.
object_storage?
uploads
.
each
do
|
upload_model
|
uploads
do
|
upload_model
|
next
unless
upload_model
.
file
next
if
upload_model
.
upload
.
local?
# Already copied, using the old method
...
...
@@ -71,13 +73,21 @@ module Gitlab
end
def
uploads
@uploads
||=
begin
avatar_path
=
@project
.
avatar
&
.
upload
&
.
path
if
@relative_export_path
==
'avatar'
[
@project
.
avatar
].
compact
yield
(
@project
.
avatar
)
else
(
@project
.
uploads
-
[
@project
.
avatar
&
.
upload
]).
map
(
&
:build_uploader
)
project_uploads
(
avatar_path
).
find_each
(
batch_size:
UPLOADS_BATCH_SIZE
)
do
|
upload
|
yield
(
upload
.
build_uploader
)
end
end
end
def
project_uploads
(
avatar_path
)
return
@project
.
uploads
unless
avatar_path
@project
.
uploads
.
where
(
"path != ?"
,
avatar_path
)
end
def
download_and_copy
(
upload
)
...
...
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