about summary refs log tree commit diff
path: root/lib/mastodon
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-10-07 20:04:56 +0200
committerGitHub <noreply@github.com>2019-10-07 20:04:56 +0200
commit0aaa3afc2df2cc2fa8cdd277cf91dcfabf45afcd (patch)
tree205c8b96867a828faf454bea908f51c56f215981 /lib/mastodon
parentebe574d5b57c647450cab3d4ca2e8ca52c4fb3fe (diff)
Add `tootctl media usage` command (#12115)
Diffstat (limited to 'lib/mastodon')
-rw-r--r--lib/mastodon/media_cli.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/mastodon/media_cli.rb b/lib/mastodon/media_cli.rb
index ec2f36c30..bb97751d5 100644
--- a/lib/mastodon/media_cli.rb
+++ b/lib/mastodon/media_cli.rb
@@ -97,5 +97,17 @@ module Mastodon
 
       say("Downloaded #{processed} media attachments (approx. #{number_to_human_size(aggregate)})#{dry_run}", :green, true)
     end
+
+    desc 'usage', 'Calculate disk space consumed by Mastodon'
+    def usage
+      say("Attachments:\t#{number_to_human_size(MediaAttachment.sum(:file_file_size))} (#{number_to_human_size(MediaAttachment.where(account: Account.local).sum(:file_file_size))} local)")
+      say("Custom emoji:\t#{number_to_human_size(CustomEmoji.sum(:image_file_size))} (#{number_to_human_size(CustomEmoji.local.sum(:image_file_size))} local)")
+      say("Preview cards:\t#{number_to_human_size(PreviewCard.sum(:image_file_size))}")
+      say("Avatars:\t#{number_to_human_size(Account.sum(:avatar_file_size))} (#{number_to_human_size(Account.local.sum(:avatar_file_size))} local)")
+      say("Headers:\t#{number_to_human_size(Account.sum(:header_file_size))} (#{number_to_human_size(Account.local.sum(:header_file_size))} local)")
+      say("Backups:\t#{number_to_human_size(Backup.sum(:dump_file_size))}")
+      say("Imports:\t#{number_to_human_size(Import.sum(:data_file_size))}")
+      say("Settings:\t#{number_to_human_size(SiteUpload.sum(:file_file_size))}")
+    end
   end
 end