# Deleting user images when using the rails console to delete users

**URL:** https://meta.discourse.org/t/deleting-user-images-when-using-the-rails-console-to-delete-users/76497
**Category:** Development
**Created:** [December 20, 2017, 5:24pm UTC](https://meta.discourse.org/t/deleting-user-images-when-using-the-rails-console-to-delete-users/76497 "2017-12-20T17:24:31Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Frank\_Bailey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/frank_bailey/32/83927_2.png) [@Frank\_Bailey](https://meta.discourse.org/u/Frank_Bailey)
#### Post date: [December 20, 2017, 5:24pm UTC](https://meta.discourse.org/t/deleting-user-images-when-using-the-rails-console-to-delete-users/76497/1 "2017-12-20T17:24:32Z")

</div>

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](https://meta.discourse.org/t/bulk-delete-suspended-users-after-import/73011/3)

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!

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [December 20, 2017, 5:26pm UTC](https://meta.discourse.org/t/deleting-user-images-when-using-the-rails-console-to-delete-users/76497/2 "2017-12-20T17:26:11Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Frank\_Bailey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/frank_bailey/32/83927_2.png) [@Frank\_Bailey](https://meta.discourse.org/u/Frank_Bailey)
#### Post date: [December 20, 2017, 5:29pm UTC](https://meta.discourse.org/t/deleting-user-images-when-using-the-rails-console-to-delete-users/76497/3 "2017-12-20T17:29:01Z")

</div>

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

Thanks AGAIN Jay! 😃

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [December 20, 2017, 5:30pm UTC](https://meta.discourse.org/t/deleting-user-images-when-using-the-rails-console-to-delete-users/76497/4 "2017-12-20T17:30:44Z")

</div>

> [@Frank\_Bailey](#):
>
> (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.

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [December 20, 2017, 5:32pm UTC](https://meta.discourse.org/t/deleting-user-images-when-using-the-rails-console-to-delete-users/76497/5 "2017-12-20T17:32:33Z")

</div>

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [December 20, 2017, 5:38pm UTC](https://meta.discourse.org/t/deleting-user-images-when-using-the-rails-console-to-delete-users/76497/6 "2017-12-20T17:38:27Z")

</div>

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?](https://meta.discourse.org/t/what-happens-if-i-manually-move-images-out-of-the-tombstone-directory/67940))

---

<div class="post-metadata">

### Author: ![Frank\_Bailey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/frank_bailey/32/83927_2.png) [@Frank\_Bailey](https://meta.discourse.org/u/Frank_Bailey)
#### Post date: [December 20, 2017, 5:40pm UTC](https://meta.discourse.org/t/deleting-user-images-when-using-the-rails-console-to-delete-users/76497/7 "2017-12-20T17:40:10Z")

</div>

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [December 20, 2017, 5:41pm UTC](https://meta.discourse.org/t/deleting-user-images-when-using-the-rails-console-to-delete-users/76497/8 "2017-12-20T17:41:40Z")

</div>

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

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [December 20, 2017, 5:45pm UTC](https://meta.discourse.org/t/deleting-user-images-when-using-the-rails-console-to-delete-users/76497/9 "2017-12-20T17:45:49Z")

</div>

You are right @pfaffman. Clean up job removes it from database only. 👍
