2021-03-11 19:13:27 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
desc "GitLab | Packages | Migrate packages files to remote storage"
|
|
|
|
namespace :gitlab do
|
|
|
|
namespace :packages do
|
|
|
|
task migrate: :environment do
|
2023-05-27 22:25:52 +05:30
|
|
|
require 'logger'
|
|
|
|
|
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
|