Last active
October 4, 2018 13:56
-
-
Save 0xa/1809a06d175f925e6820cd8240516615 to your computer and use it in GitHub Desktop.
mastodon tootctl media remove progressbar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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