debian-mirror-gitlab/lib/tasks/gitlab/packages/migrate.rake

26 lines
916 B
Ruby
Raw Normal View History

2021-03-11 19:13:27 +05:30
# frozen_string_literal: true
2020-07-28 23:09:34 +05:30
require 'logger'
desc "GitLab | Packages | Migrate packages files to remote storage"
namespace :gitlab do
namespace :packages do
task migrate: :environment do
2021-09-04 01:27:46 +05:30
logger = Logger.new($stdout)
2020-07-28 23:09:34 +05:30
logger.info('Starting transfer of package files to object storage')
unless ::Packages::PackageFileUploader.object_store_enabled?
raise 'Object store is disabled for packages feature'
end
::Packages::PackageFile.with_files_stored_locally.find_each(batch_size: 10) do |package_file|
package_file.file.migrate!(::Packages::PackageFileUploader::Store::REMOTE)
logger.info("Transferred package file #{package_file.id} of size #{package_file.size.to_i.bytes} to object storage")
2021-06-08 01:23:25 +05:30
rescue StandardError => e
2020-07-28 23:09:34 +05:30
logger.error("Failed to transfer package file #{package_file.id} with error: #{e.message}")
end
end
end
end