Does the Purge Deleted Uploads Grace Period Setting Work?

The purge_deleted_uploads_grace_period_days setting determines how long (in days) deleted uploads should remain in the system before being permanently erased. This process relies on uploads being considered “orphaned” to be eligible for deletion.

To fully remove an upload from Discourse, you’ll have to do one of the following:

  • Force the upload to become orphaned by removing any reference to the upload. This can be done by editing the upload link out of the post that it’s in, or any other places the upload may be referenced.
  • Delete any and all topics/posts containing the upload, causing the upload to be considered as “deleted”. Note that you need to remove the image from the post before deleting the post to orphan it.

All orphaned unreferenced uploads and deleted uploads will then be removed from storage (after a grace period set by the purge deleted uploads grace period days setting) once the clean up uploads job runs.

If you’re having trouble with deleted posts not being purged as expected here are a couple things you could check:

  • Verify that the clean_orphan_uploads_grace_period_hours setting is also set appropriately. This controls when unused (orphaned) uploads are deleted.
  • Make sure the deleted uploads are no longer referenced in the respective posts. If a post with a deleted upload still references it, the system may not consider the upload to be “orphaned.”

For reference, we also have a guide about Cleaning up uploads and purging uploads from S3 that has more information about how orphaned and deleted uploads are automatically purged from a Discourse site.

2 Likes