Reduce storage overhead of account headers
Account headers (i.e., the background image behind people's account pages) seem to never be pruned and constantly growing, currently taking up much more storage for my instance than any other media type.
I know we have a rake task to prune old media attachments, but I assume we do not touch headers because a single user could post frequently.
Is there a possible expiration pattern to keep this part of the data from constantly increasing?
Can we expire the local copy on users that haven't posted in a while? Can we link back to their instance for those cases?
- [x] I searched or browsed the repo’s other issues to ensure this is not a duplicate.
- [x] This bug happens on a tagged release and not on
master(If you're a user, don't worry about this).
Based on default paperclip rules, avatars and headers that have been changed should be being deleted.
For remote accounts, you could setup a rake task to do the following:
Account.remote.where("updated_at < ?", 10.days.ago).each{ |account|
account.avatar = nil
account.header = nil
account.avatar_remote_url = ''
account.header_remote_url = ''
account.save
}
Thank you!
👍for this becoming a rake task included in Mastodon.
Would like to give an additional shout out to this issue as well as requesting the cleanup of preview cards. My instance currently takes up 10GB, 4GB of which is caused by account headers and another 4GB is used for preview cards.
Being able to clean these up would be majorly beneficial for storage use.
@ThisIsMissEm Would you know if this snippet still works? Not sure how would I run this (not using docker)
Any tips would be very appreciated.
Thank you
@quicoto you'd have to try it and find out, I honestly don't know, it's been 4 years since I last touched the mastodon codebase.