diff options
author | George Claghorn <george@basecamp.com> | 2019-05-22 15:07:35 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-22 15:07:35 -0400 |
commit | d5a2f7ec148726d7547e367d7a968e3b4be9b509 (patch) | |
tree | 1818959b09d3bdde9b43440fe5ca8fa402984ec3 /activestorage/app/jobs/active_storage | |
parent | ff34f78248e367fdc7d59b42b37610427f7339c8 (diff) | |
download | rails-d5a2f7ec148726d7547e367d7a968e3b4be9b509.tar.gz rails-d5a2f7ec148726d7547e367d7a968e3b4be9b509.tar.bz2 rails-d5a2f7ec148726d7547e367d7a968e3b4be9b509.zip |
Mirror direct uploads
Diffstat (limited to 'activestorage/app/jobs/active_storage')
-rw-r--r-- | activestorage/app/jobs/active_storage/mirror_job.rb | 13 |
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 |