2018-02-21 21:09:53 +00:00
|
|
|
# @Deprecated - remove once the `object_storage_upload` queue is empty
|
|
|
|
# The queue has been renamed `object_storage:object_storage_background_upload`
|
|
|
|
#
|
2017-09-07 21:27:04 +00:00
|
|
|
class ObjectStorageUploadWorker
|
2018-02-21 21:09:53 +00:00
|
|
|
include ApplicationWorker
|
2017-09-07 21:27:04 +00:00
|
|
|
|
2017-12-08 09:09:06 +00:00
|
|
|
sidekiq_options retry: 5
|
|
|
|
|
2017-09-07 21:27:04 +00:00
|
|
|
def perform(uploader_class_name, subject_class_name, file_field, subject_id)
|
|
|
|
uploader_class = uploader_class_name.constantize
|
|
|
|
subject_class = subject_class_name.constantize
|
|
|
|
|
2018-02-02 13:59:43 +00:00
|
|
|
return unless uploader_class < ObjectStorage::Concern
|
2017-09-07 21:27:04 +00:00
|
|
|
return unless uploader_class.object_store_enabled?
|
|
|
|
return unless uploader_class.background_upload_enabled?
|
|
|
|
|
2018-02-02 13:59:43 +00:00
|
|
|
subject = subject_class.find(subject_id)
|
|
|
|
uploader = subject.public_send(file_field) # rubocop:disable GitlabSecurity/PublicSend
|
|
|
|
uploader.migrate!(ObjectStorage::Store::REMOTE)
|
2017-09-07 21:27:04 +00:00
|
|
|
end
|
|
|
|
end
|