# 如何使图片成为孤儿以便删除？

**URL:** https://meta.discourse.org/t/how-to-make-an-image-orphaned-so-that-it-gets-removed/79231
**Category:** Support
**Created:** [2018年一月29日 00:52 UTC](https://meta.discourse.org/t/how-to-make-an-image-orphaned-so-that-it-gets-removed/79231 "2018-01-29T00:52:45Z")
**Posts on this page:** 1
**Showing post:** 21

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [2021年八月25日 14:40 UTC](https://meta.discourse.org/t/how-to-make-an-image-orphaned-so-that-it-gets-removed/79231/21 "2021-08-25T14:40:01Z")

</div>

> [@sam](#):
>
> 首先我们需要那个 Rake 任务，这已经明确排期了。有了它之后，我们还可以添加一个站点设置，默认关闭此行为。比如叫 `purge_images_from_deleted_posts_days` 之类的。

这些措施落实了吗？我找不到能删除已删除帖子中图片的 Rake 任务或设置。

当我查看我们实例中旧的已删除帖子（超过 1 年）时，图片仍然在那里。

这目前很重要，因为我们正在迁移实例的一部分，这将涉及大量主题删除以及需要清理的历史上传文件。

另一种解决方式是直接从数据库中清除已删除的帖子和主题，但我也看不出该如何操作。

## 附注：

后续讨论在此：

> [@Any api to purge old deleted posts / uploads](https://meta.discourse.org/t/any-api-to-purge-old-deleted-posts-uploads/73495/7):
>
> Call for Help! Can a clever person walk me through combining: AND to make an awesome orphaned uploads purger run from the console? I note that when I use rails db, I’m asked for Password for user discourse:. What do I do with that?

---

_[View the full topic](https://meta.discourse.org/t/how-to-make-an-image-orphaned-so-that-it-gets-removed/79231)._
