Deleting user images when using the rails console to delete users

(Frank Bailey) #1

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

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?


(Jay Pfaffman) #2

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

(Frank Bailey) #3

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

(Jay Pfaffman) #4

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.

(Vinoth Kannan) #5

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

(Jay Pfaffman) #6

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

(Frank Bailey) #7

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

(Jay Pfaffman) #8

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

(Vinoth Kannan) #9

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