PERF: Release post_upload records when downloaded image is removed (#10379)

Previously we would unconditionally keep all images downloaded via pull_hotlinked_images, even if they are later removed from the post. This commit removes that logic, and relies on the existing link_post_uploads process to pick up the downloaded images in `cooked`. Specs are added to ensure this is working correctly for regular hotlinked images, and for oneboxes.
This commit is contained in:
David Taylor
2020-08-06 01:06:34 +01:00
committed by GitHub
parent 09254410ea
commit ceb858c70a
2 changed files with 36 additions and 9 deletions

View File

@ -915,7 +915,6 @@ class Post < ActiveRecord::Base
upload_ids << upload.id if upload.present?
end
upload_ids |= Upload.where(id: downloaded_images.values).pluck(:id)
post_uploads = upload_ids.map do |upload_id|
{ post_id: self.id, upload_id: upload_id }
end