From dae0d809ea66ac76bac63f17b6c4f9c8ce360a06 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Fri, 13 Jul 2018 15:41:24 +0200 Subject: [PATCH] refactor uploads manager --- lib/gitlab/import_export/uploads_manager.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/gitlab/import_export/uploads_manager.rb b/lib/gitlab/import_export/uploads_manager.rb index 3e756bdaa79..4af547e616e 100644 --- a/lib/gitlab/import_export/uploads_manager.rb +++ b/lib/gitlab/import_export/uploads_manager.rb @@ -56,11 +56,11 @@ module Gitlab def copy_from_object_storage return unless Gitlab::ImportExport.object_storage? - uploads do |upload_model| - next unless upload_model.file - next if upload_model.upload.local? # Already copied, using the old method + uploaders do |uploader| + next unless uploader.file + next if uploader.upload.local? # Already copied, using the old method - download_and_copy(upload_model) + download_and_copy(uploader) end end @@ -72,19 +72,19 @@ module Gitlab @uploads_export_path ||= File.join(@shared.export_path, @relative_export_path) end - def uploads + def uploader avatar_path = @project.avatar&.upload&.path if @relative_export_path == 'avatar' yield(@project.avatar) 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) end end end - def project_uploads(avatar_path) + def project_uploads_or_avatar(avatar_path) return @project.uploads unless avatar_path @project.uploads.where("path != ?", avatar_path)