mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Trigger before upload event after saving and before uploading it, so we are sure that the upload is valid. (#10269)
This commit is contained in:
parent
98eb7a3f00
commit
2abfd30d22
@ -39,8 +39,6 @@ class UploadCreator
|
|||||||
is_image ||= @image_info && FileHelper.is_supported_image?("test.#{@image_info.type}")
|
is_image ||= @image_info && FileHelper.is_supported_image?("test.#{@image_info.type}")
|
||||||
is_image = false if @opts[:for_theme]
|
is_image = false if @opts[:for_theme]
|
||||||
|
|
||||||
DiscourseEvent.trigger(:before_upload_creation, @file, is_image)
|
|
||||||
|
|
||||||
DistributedMutex.synchronize("upload_#{user_id}_#{@filename}") do
|
DistributedMutex.synchronize("upload_#{user_id}_#{@filename}") do
|
||||||
if is_image
|
if is_image
|
||||||
extract_image_info!
|
extract_image_info!
|
||||||
@ -124,6 +122,8 @@ class UploadCreator
|
|||||||
add_metadata!
|
add_metadata!
|
||||||
return @upload unless @upload.save
|
return @upload unless @upload.save
|
||||||
|
|
||||||
|
DiscourseEvent.trigger(:before_upload_creation, @file, is_image)
|
||||||
|
|
||||||
# store the file and update its url
|
# store the file and update its url
|
||||||
File.open(@file.path) do |f|
|
File.open(@file.path) do |f|
|
||||||
url = Discourse.store.store_upload(f, @upload)
|
url = Discourse.store.store_upload(f, @upload)
|
||||||
|
Loading…
Reference in New Issue
Block a user