aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/app/jobs/active_storage/mirror_job.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activestorage/app/jobs/active_storage/mirror_job.rb')
-rw-r--r--activestorage/app/jobs/active_storage/mirror_job.rb13
1 files changed, 13 insertions, 0 deletions
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