]> cat aescling's git repositories - mastodon.git/commitdiff
Fix #3904 - Adjustable time period for mastodon:media:remove_remote via NUM_DAYS...
authorEugen Rochko <eugen@zeonfederated.com>
Fri, 14 Jul 2017 01:51:17 +0000 (03:51 +0200)
committerGitHub <noreply@github.com>
Fri, 14 Jul 2017 01:51:17 +0000 (03:51 +0200)
lib/tasks/mastodon.rake

index b2b35285842d4221b2abcdbe1cca36a2ccab67a6..1b05ece33f87c3e7aa69a273738f05c29321b7b1 100644 (file)
@@ -85,9 +85,11 @@ namespace :mastodon do
       MediaAttachment.where(account: Account.silenced).find_each(&:destroy)
     end
 
-    desc 'Remove cached remote media attachments that are older than a week'
+    desc 'Remove cached remote media attachments that are older than NUM_DAYS. By default 7 (week)'
     task remove_remote: :environment do
-      MediaAttachment.where.not(remote_url: '').where('created_at < ?', 1.week.ago).find_each do |media|
+      time_ago = ENV.fetch('NUM_DAYS') { 7 }.to_i.days.ago
+
+      MediaAttachment.where.not(remote_url: '').where('created_at < ?', time_ago).find_each do |media|
         media.file.destroy
         media.type = :unknown
         media.save