diff options
Diffstat (limited to 'app/workers/maintenance/uncache_media_worker.rb')
-rw-r--r-- | app/workers/maintenance/uncache_media_worker.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/workers/maintenance/uncache_media_worker.rb b/app/workers/maintenance/uncache_media_worker.rb new file mode 100644 index 00000000000..f6a51a1b8b2 --- /dev/null +++ b/app/workers/maintenance/uncache_media_worker.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class Maintenance::UncacheMediaWorker + include Sidekiq::Worker + + sidekiq_options queue: 'pull' + + def perform(media_attachment_id) + media = MediaAttachment.find(media_attachment_id) + + return unless media.file.exists? + + media.file.destroy + media.save + rescue ActiveRecord::RecordNotFound + true + end +end |