about summary refs log tree commit diff
path: root/app/workers/maintenance
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2018-08-25 13:25:39 +0200
committerGitHub <noreply@github.com>2018-08-25 13:25:39 +0200
commit793eea29823a44fd4950f87898ecf0ff3b49351d (patch)
tree3b8f21b5d4fa500d50a3e014140166348c1c1e17 /app/workers/maintenance
parentb4fc810bc34eb58e2c9e6c5abb2de2d6d9390a9b (diff)
Add improved CLI interface for removing remote media (#8411)
./bin/tootctl media remove --days 7 --background

Make the old rake task point to it
Diffstat (limited to 'app/workers/maintenance')
-rw-r--r--app/workers/maintenance/destroy_media_worker.rb2
-rw-r--r--app/workers/maintenance/redownload_account_media_worker.rb2
-rw-r--r--app/workers/maintenance/uncache_media_worker.rb2
3 files changed, 3 insertions, 3 deletions
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?