summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-09-19 09:15:36 +0000
committerDouwe Maan <douwe@gitlab.com>2018-09-19 09:15:36 +0000
commite23d08c72a0abae9c5aef91b76e3e21f2c5d0fea (patch)
tree74422925a0faab879554bb0f1656787b44dbc9d6 /lib
parent2dac058de25dc6ed03d0ed6f8b099aa17cdc1cab (diff)
parent6a4d1b63fe0d8f928c3633378753adb8e3c320f8 (diff)
downloadgitlab-ce-e23d08c72a0abae9c5aef91b76e3e21f2c5d0fea.tar.gz
Merge branch '51571-wrapper-rake-task-uploads-migrate-os' into 'master'
Add wrapper rake task to migrate all uploads to OS Closes #51571 See merge request gitlab-org/gitlab-ce!21779
Diffstat (limited to 'lib')
-rw-r--r--lib/tasks/gitlab/uploads/migrate.rake26
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/tasks/gitlab/uploads/migrate.rake b/lib/tasks/gitlab/uploads/migrate.rake
index f548a266b99..1c93609a006 100644
--- a/lib/tasks/gitlab/uploads/migrate.rake
+++ b/lib/tasks/gitlab/uploads/migrate.rake
@@ -1,6 +1,30 @@
namespace :gitlab do
namespace :uploads do
- desc 'GitLab | Uploads | Migrate the uploaded files to object storage'
+ namespace :migrate do
+ desc "GitLab | Uploads | Migrate all uploaded files to object storage"
+ task all: :environment do
+ 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(FileUploader MergeRequest)]
+
+ categories.each do |args|
+ Rake::Task["gitlab:uploads:migrate"].invoke(*args)
+ Rake::Task["gitlab:uploads:migrate"].reenable
+ end
+ end
+ end
+
+ # The following is the actual rake task that migrates uploads of specified
+ # category to object storage
+ desc 'GitLab | Uploads | Migrate the uploaded files of specified type to object storage'
task :migrate, [:uploader_class, :model_class, :mounted_as] => :environment do |task, args|
batch_size = ENV.fetch('BATCH', 200).to_i
@to_store = ObjectStorage::Store::REMOTE