Commit 97ce0607 authored by James Lopez's avatar James Lopez

refactor code based on feedback

parent 07ec2c7b
...@@ -51,7 +51,7 @@ module Gitlab ...@@ -51,7 +51,7 @@ module Gitlab
def copy_from_object_storage def copy_from_object_storage
return unless Gitlab::ImportExport.object_storage? return unless Gitlab::ImportExport.object_storage?
uploaders do |uploader| each_uploader do |uploader|
next unless uploader.file next unless uploader.file
next if uploader.upload.local? # Already copied, using the old method next if uploader.upload.local? # Already copied, using the old method
...@@ -67,19 +67,19 @@ module Gitlab ...@@ -67,19 +67,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 uploaders def each_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_or_avatar(avatar_path).find_each(batch_size: UPLOADS_BATCH_SIZE) do |upload| project_uploads_except_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_or_avatar(avatar_path) def project_uploads_except_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)
......
...@@ -12,7 +12,7 @@ module Gitlab ...@@ -12,7 +12,7 @@ module Gitlab
true true
else else
true true # Proceed without uploads
end end
rescue => e rescue => e
@shared.error(e) @shared.error(e)
......
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