diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-07-14 03:51:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-14 03:51:17 +0200 |
commit | 27b2355738482a2e470281136bfe902ad6c78db8 (patch) | |
tree | 16788942ba8283c5c400be215e9e974be2f248ac /lib | |
parent | eeb5923e89c1b9040df37db8709e3450713c6019 (diff) |
Fix #3904 - Adjustable time period for mastodon:media:remove_remote via NUM_DAYS (#4191)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tasks/mastodon.rake | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index b2b352858..1b05ece33 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -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 |