Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/uploads/migration_helper.rb')
-rw-r--r--lib/gitlab/uploads/migration_helper.rb38
1 files changed, 10 insertions, 28 deletions
diff --git a/lib/gitlab/uploads/migration_helper.rb b/lib/gitlab/uploads/migration_helper.rb
index deab2cd43a6..712512d0e02 100644
--- a/lib/gitlab/uploads/migration_helper.rb
+++ b/lib/gitlab/uploads/migration_helper.rb
@@ -5,27 +5,10 @@ module Gitlab
class MigrationHelper
attr_reader :logger
- CATEGORIES = [%w(AvatarUploader Project :avatar),
- %w(AvatarUploader Group :avatar),
- %w(AvatarUploader User :avatar),
- %w(AttachmentUploader Note :attachment),
- %w(AttachmentUploader Appearance :logo),
- %w(AttachmentUploader Appearance :header_logo),
- %w(FaviconUploader Appearance :favicon),
- %w(FileUploader Project),
- %w(PersonalFileUploader Snippet),
- %w(NamespaceFileUploader Snippet),
- %w(DesignManagement::DesignV432x230Uploader DesignManagement::Action :image_v432x230),
- %w(FileUploader MergeRequest)].freeze
-
def initialize(args, logger)
prepare_variables(args, logger)
end
- def self.categories
- CATEGORIES
- end
-
def migrate_to_remote_storage
@to_store = ObjectStorage::Store::REMOTE
@@ -45,17 +28,14 @@ module Gitlab
end
def prepare_variables(args, logger)
- @mounted_as = args.mounted_as&.gsub(':', '')&.to_sym
- @uploader_class = args.uploader_class.constantize
- @model_class = args.model_class.constantize
+ @mounted_as = args.mounted_as&.gsub(':', '')
+ @uploader_class = args.uploader_class
+ @model_class = args.model_class&.constantize
@logger = logger
end
def enqueue_batch(batch, index)
- job = ObjectStorage::MigrateUploadsWorker.enqueue!(batch,
- @model_class,
- @mounted_as,
- @to_store)
+ job = ObjectStorage::MigrateUploadsWorker.enqueue!(batch, @to_store)
logger.info(message: "[Uploads migration] Enqueued upload migration job", index: index, job_id: job)
rescue ObjectStorage::MigrateUploadsWorker::SanityCheckError => e
# continue for the next batch
@@ -66,10 +46,12 @@ module Gitlab
def uploads(store_type = [nil, ObjectStorage::Store::LOCAL])
Upload.class_eval { include EachBatch } unless Upload < EachBatch
- Upload
- .where(store: store_type,
- uploader: @uploader_class.to_s,
- model_type: @model_class.base_class.sti_name)
+ uploads = Upload.where(store: store_type)
+ uploads = uploads.where(uploader: @uploader_class) if @uploader_class.present?
+ uploads = uploads.where(model_type: @model_class.base_class.sti_name) if @model_class.present?
+ uploads = uploads.where(mount_point: @mounted_as) if @mounted_as.present?
+
+ uploads
end
# rubocop:enable CodeReuse/ActiveRecord
end