diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2019-09-10 15:29:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-10 15:29:12 +0200 |
commit | 031ca25014e0ba88d3dcc3086947b41449a672e2 (patch) | |
tree | 405ee6477c1406034faf4dbdfb6139d4090e9005 /app/workers | |
parent | 86748148256b504c0411119628435b1445959309 (diff) |
Add retry for failed media downloads and `tootctl media refresh` (#11775)
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/redownload_media_worker.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/workers/redownload_media_worker.rb b/app/workers/redownload_media_worker.rb new file mode 100644 index 000000000..98e995918 --- /dev/null +++ b/app/workers/redownload_media_worker.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class RedownloadMediaWorker + include Sidekiq::Worker + include ExponentialBackoff + + sidekiq_options queue: 'pull', retry: 3 + + def perform(id) + media_attachment = MediaAttachment.find(id) + + return if media_attachment.remote_url.blank? + + media_attachment.reset_file! + media_attachment.save + rescue ActiveRecord::RecordNotFound + true + end +end |