mastodon icon indicating copy to clipboard operation
mastodon copied to clipboard

Reduce storage overhead of account headers

Open fwenzel opened this issue 8 years ago • 6 comments

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).

fwenzel avatar Apr 05 '18 23:04 fwenzel

Based on default paperclip rules, avatars and headers that have been changed should be being deleted.

ThisIsMissEm avatar Apr 07 '18 07:04 ThisIsMissEm

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
}

ThisIsMissEm avatar Apr 07 '18 07:04 ThisIsMissEm

Thank you!

fwenzel avatar Apr 13 '18 04:04 fwenzel

👍for this becoming a rake task included in Mastodon.

davidwolfpaw avatar Jun 05 '18 23:06 davidwolfpaw

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.

noirscape avatar May 27 '19 11:05 noirscape

@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 avatar Nov 13 '22 08:11 quicoto

@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.

ThisIsMissEm avatar Nov 13 '22 20:11 ThisIsMissEm