From d5a2f7ec148726d7547e367d7a968e3b4be9b509 Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Wed, 22 May 2019 15:07:35 -0400 Subject: Mirror direct uploads --- activestorage/app/jobs/active_storage/mirror_job.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 activestorage/app/jobs/active_storage/mirror_job.rb (limited to 'activestorage/app/jobs') diff --git a/activestorage/app/jobs/active_storage/mirror_job.rb b/activestorage/app/jobs/active_storage/mirror_job.rb new file mode 100644 index 0000000000..e34faedb56 --- /dev/null +++ b/activestorage/app/jobs/active_storage/mirror_job.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +# Provides asynchronous mirroring of directly-uploaded blobs. +class ActiveStorage::MirrorJob < ActiveStorage::BaseJob + queue_as { ActiveStorage.queues[:mirror] } + + discard_on ActiveStorage::FileNotFoundError + retry_on ActiveStorage::IntegrityError, attempts: 10, wait: :exponentially_longer + + def perform(key, checksum:) + ActiveStorage::Blob.service.try(:mirror, key, checksum: checksum) + end +end -- cgit v1.2.3