FIX: disallow concurrent downloads of hotlinked images (#27676)
This commit is contained in:
parent
7c26d5d084
commit
61610a61fa
|
@ -14,6 +14,17 @@ module Jobs
|
|||
@post_id = args[:post_id]
|
||||
raise Discourse::InvalidParameters.new(:post_id) if @post_id.blank?
|
||||
|
||||
# in test we have no choice cause we don't want to cause a deadlock
|
||||
if Jobs.run_immediately?
|
||||
pull_hotlinked_images
|
||||
else
|
||||
DistributedMutex.synchronize("pull_hotlinked_images_#{@post_id}", validity: 2.minutes) do
|
||||
pull_hotlinked_images
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pull_hotlinked_images
|
||||
post = Post.find_by(id: @post_id)
|
||||
return if post.nil? || post.topic.nil?
|
||||
|
||||
|
|
Loading…
Reference in New Issue