This commit is contained in:
Matt Jankowski 2024-04-26 18:07:06 +00:00 committed by GitHub
commit 1f0153c3cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 47 additions and 7 deletions

View File

@ -278,13 +278,13 @@ module Mastodon::CLI
desc 'usage', 'Calculate disk space consumed by Mastodon'
def usage
say("Attachments:\t#{number_to_human_size(media_attachment_storage_size)} (#{number_to_human_size(local_media_attachment_storage_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))}")
say("Custom emoji:\t#{number_to_human_size(custom_emoji_storage_size)} (#{number_to_human_size(local_custom_emoji_storage_size)} local)")
say("Preview cards:\t#{number_to_human_size(preview_card_storage_size)}")
say("Avatars:\t#{number_to_human_size(avatar_storage_size)} (#{number_to_human_size(local_avatar_storage_size)} local)")
say("Headers:\t#{number_to_human_size(header_storage_size)} (#{number_to_human_size(local_header_storage_size)} local)")
say("Backups:\t#{number_to_human_size(backups_storage_size)}")
say("Imports:\t#{number_to_human_size(imports_storage_size)}")
say("Settings:\t#{number_to_human_size(settings_storage_size)}")
end
desc 'lookup URL', 'Lookup where media is displayed by passing a media URL'
@ -333,6 +333,46 @@ module Mastodon::CLI
)
end
def custom_emoji_storage_size
CustomEmoji.sum(:image_file_size)
end
def local_custom_emoji_storage_size
CustomEmoji.local.sum(:image_file_size)
end
def preview_card_storage_size
PreviewCard.sum(:image_file_size)
end
def avatar_storage_size
Account.sum(:avatar_file_size)
end
def local_avatar_storage_size
Account.local.sum(:avatar_file_size)
end
def header_storage_size
Account.sum(:header_file_size)
end
def local_header_storage_size
Account.local.sum(:header_file_size)
end
def backups_storage_size
Backup.sum(:dump_file_size)
end
def imports_storage_size
Import.sum(:data_file_size)
end
def settings_storage_size
SiteUpload.sum(:file_file_size)
end
PRELOAD_MODEL_WHITELIST = %w(
Account
Backup