Commit dae0d809 authored by James Lopez's avatar James Lopez

refactor uploads manager

parent c2d297d9
...@@ -56,11 +56,11 @@ module Gitlab ...@@ -56,11 +56,11 @@ module Gitlab
def copy_from_object_storage def copy_from_object_storage
return unless Gitlab::ImportExport.object_storage? return unless Gitlab::ImportExport.object_storage?
uploads do |upload_model| uploaders do |uploader|
next unless upload_model.file next unless uploader.file
next if upload_model.upload.local? # Already copied, using the old method next if uploader.upload.local? # Already copied, using the old method
download_and_copy(upload_model) download_and_copy(uploader)
end end
end end
...@@ -72,19 +72,19 @@ module Gitlab ...@@ -72,19 +72,19 @@ module Gitlab
@uploads_export_path ||= File.join(@shared.export_path, @relative_export_path) @uploads_export_path ||= File.join(@shared.export_path, @relative_export_path)
end end
def uploads def uploader
avatar_path = @project.avatar&.upload&.path avatar_path = @project.avatar&.upload&.path
if @relative_export_path == 'avatar' if @relative_export_path == 'avatar'
yield(@project.avatar) yield(@project.avatar)
else else
project_uploads(avatar_path).find_each(batch_size: UPLOADS_BATCH_SIZE) do |upload| project_uploads_or_avatar(avatar_path).find_each(batch_size: UPLOADS_BATCH_SIZE) do |upload|
yield(upload.build_uploader) yield(upload.build_uploader)
end end
end end
end end
def project_uploads(avatar_path) def project_uploads_or_avatar(avatar_path)
return @project.uploads unless avatar_path return @project.uploads unless avatar_path
@project.uploads.where("path != ?", avatar_path) @project.uploads.where("path != ?", avatar_path)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment