Skip to content

Instantly share code, notes, and snippets.

@0xa
Last active October 4, 2018 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xa/1809a06d175f925e6820cd8240516615 to your computer and use it in GitHub Desktop.
Save 0xa/1809a06d175f925e6820cd8240516615 to your computer and use it in GitHub Desktop.
mastodon tootctl media remove progressbar
# in lib/mastodon/media_cli.rb:43
# also gem install ruby-progressbar
# probably awful i dislike ruby lol
say("counting...")
count = MediaAttachment.where.not(remote_url: '').where.not(file_file_name: nil).where('created_at < ?', time_ago).count
say("removing #{count} files...")
bar = ProgressBar.create(:total => count, :length => 80, :format => "%a [%c/%C] |%B| %j%% %f")
MediaAttachment.where.not(remote_url: '').where.not(file_file_name: nil).where('created_at < ?', time_ago).reorder(nil).find_in_batches do |media_attachments|
media_attachments.each do |m|
Maintenance::UncacheMediaWorker.new.perform(m) unless options[:dry_run]
#options[:verbose] ? say("\rprocessed=#{processed}/#{count} last_id=#{m.id}", nil, false) : say('.', :green, false)
processed += 1
bar.increment
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment