From 793eea29823a44fd4950f87898ecf0ff3b49351d Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 25 Aug 2018 13:25:39 +0200 Subject: Add improved CLI interface for removing remote media (#8411) ./bin/tootctl media remove --days 7 --background Make the old rake task point to it --- app/workers/maintenance/destroy_media_worker.rb | 2 +- app/workers/maintenance/redownload_account_media_worker.rb | 2 +- app/workers/maintenance/uncache_media_worker.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'app/workers') diff --git a/app/workers/maintenance/destroy_media_worker.rb b/app/workers/maintenance/destroy_media_worker.rb index 5f052983b..cde33d6d7 100644 --- a/app/workers/maintenance/destroy_media_worker.rb +++ b/app/workers/maintenance/destroy_media_worker.rb @@ -6,7 +6,7 @@ class Maintenance::DestroyMediaWorker sidekiq_options queue: 'pull' def perform(media_attachment_id) - media = MediaAttachment.find(media_attachment_id) + media = media_attachment_id.is_a?(MediaAttachment) ? media_attachment_id : MediaAttachment.find(media_attachment_id) media.destroy rescue ActiveRecord::RecordNotFound true diff --git a/app/workers/maintenance/redownload_account_media_worker.rb b/app/workers/maintenance/redownload_account_media_worker.rb index fc26815f2..6afbe6e19 100644 --- a/app/workers/maintenance/redownload_account_media_worker.rb +++ b/app/workers/maintenance/redownload_account_media_worker.rb @@ -6,7 +6,7 @@ class Maintenance::RedownloadAccountMediaWorker sidekiq_options queue: 'pull', retry: false def perform(account_id) - account = Account.find(account_id) + account = account_id.is_a?(Account) ? account_id : Account.find(account_id) account.reset_avatar! account.reset_header! account.save diff --git a/app/workers/maintenance/uncache_media_worker.rb b/app/workers/maintenance/uncache_media_worker.rb index 2d1a670a7..4bc62ef75 100644 --- a/app/workers/maintenance/uncache_media_worker.rb +++ b/app/workers/maintenance/uncache_media_worker.rb @@ -6,7 +6,7 @@ class Maintenance::UncacheMediaWorker sidekiq_options queue: 'pull' def perform(media_attachment_id) - media = MediaAttachment.find(media_attachment_id) + media = media_attachment_id.is_a?(MediaAttachment) ? media_attachment_id : MediaAttachment.find(media_attachment_id) return if media.file.blank? -- cgit