After deleting several thousand posts with photos the uploads in the admin section remains the same. This setting was set to 1. Is there a way to purge all the uploads associated with deleted posts faster?
purge deleted uploads grace period days
Grace period (in days) before a deleted upload is erased.
I did this what I saw in another post but after rebuilding nothing was gone
Im not sure I understand this. I have not uploaded anything but deleted posts and categories on a test site. Theres no users right now and its been about 3 hours or so. from 13.7 to now showing this. Orphans uploads set to delete in an hour and hasnt happened.
I see this thread that discusses alot but nothing happened?
Then this one here.
and Ive tried everything in rails mentioned, sidekiq, and with commands in that thread and still nothing deletes. Over should be hundreds if not thousands of images deleted as the users posts removed posted photos with every thread.
I don’t think the post_uploads table exists any more. It’s now uploads and upload_references. You may need to update that old snippet to take that into account if you’re trying that method.
How have you deleted those posts? Just soft-deleting in the UI? I think the setting that cleans up orphaned images (clean orphan uploads grace period hours) doesn’t take into account whether they’re soft-deleted, and only cares if the image is still in the latest version of the post:
I think you can select all the posts in the rails console and use the PostDestroyer on them to hard delete them, and then the uploads will get cleaned up the next time Jobs::CleanUpUploads runs (or is manually triggered).
If it’s a whole category, for instance, I think you can use something like this:
category = Category.where(id: CATEGORY_ID).pluck(:id)
topic = Topic.where(category_id: category).pluck(:id)
topic.each do |t|
Post.where(topic_id: t).find_each do |p|
PostDestroyer.new(Discourse.system_user, p).destroy
p.destroy!
end
end