Deleting user images when using the rails console to delete users

AI-generated summary

Deleting User Images After Removing Users in Rails Console

Frank_Bailey has 17,000+ users to delete and wants to know how to remove their avatar images. pfaffman explains that unlinked images are moved to a “tombstone” directory and deleted after a certain period. Initially, it was thought to be 30 days, but vinothkannans points out that the actual period is set by the clean_orphan_uploads_grace_period_hours site setting (default 48 hours).

pfaffman clarifies that this setting determines how long before images are moved to the tombstone folder. Manually deleting images from the tombstone folder is possible, but pfaffman advises against it, as they would be permanently deleted.

Frank_Bailey mentions that the accumulated space of 17,000+ avatars is significant (around 2.5 GB). pfaffman suggests running ./launcher clean up to reclaim space from Docker. vinothkannans agrees that this command only removes files from the database.

I added over 17000 users to my client’s Discourse installation via the API. I have to delete them now because reasons.

I’ve worked out how to delete the users themselves via the Rails app as explained here: Bulk delete suspended users after import - #3 by vinothkannans

This doesn’t seem to delete the user avatar pictures (unless Discourse is caching them?) so I was wondering if anyone can tell me where I can go in the DigitalOcean droplet to delete the images?

Thanks!

They’ll get deleted eventually. A process runs and moves unlinked images to a “tombstone” directory and then they get deleted 30 days later.

Oh cool. 30 days might be a bit long but that’s good to know.

Thanks AGAIN Jay! :smiley:

(Just for my own curiosity, what’d happen if one were to manually delete images from the Tombstone folder?)

It would be deleted and you couldn’t decide later that you want it back. Avatars ain’t that big, so it wouldn’t seem like a huge problem.

I think it is not 30 days. We have site setting for that as clean_orphan_uploads_grace_period_hours (default 48).

I’m pretty sure that clean_orphan_uploads_grace_period_hours is how long before stuff gets moved to the tombstone folder (e.g., What happens if I manually move images out of the tombstone directory?)

It becomes a bigger problem when you realize that 17000+ avatars takes up around 2.5 gigabytes of space… :wink:

I see. You might do a ./launcher cleanup to get back some space from Docker.

You are right @pfaffman. Clean up job removes it from database only. :+1: