mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Didn't delete upload stub when a new upload is created
Reuse `Discourse.store` to prevent creation of multiple new store objects within `UploadCreator#create_for`.
This commit is contained in:
parent
2d6ef232a7
commit
235f172b9c
@ -196,21 +196,24 @@ class UploadCreator
|
|||||||
Upload.generate_digest(@file) != sha1_before_changes
|
Upload.generate_digest(@file) != sha1_before_changes
|
||||||
end
|
end
|
||||||
|
|
||||||
if @opts[:existing_external_upload_key] && Discourse.store.external?
|
store = Discourse.store
|
||||||
|
|
||||||
|
if @opts[:existing_external_upload_key] && store.external?
|
||||||
should_move = external_upload_too_big || !upload_changed
|
should_move = external_upload_too_big || !upload_changed
|
||||||
end
|
end
|
||||||
|
|
||||||
if should_move
|
if should_move
|
||||||
# move the file in the store instead of reuploading
|
# move the file in the store instead of reuploading
|
||||||
url = Discourse.store.move_existing_stored_upload(
|
url = store.move_existing_stored_upload(
|
||||||
existing_external_upload_key: @opts[:existing_external_upload_key],
|
existing_external_upload_key: @opts[:existing_external_upload_key],
|
||||||
upload: @upload
|
upload: @upload
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
# 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 = store.store_upload(f, @upload)
|
||||||
end
|
end
|
||||||
|
store.delete_file(@opts[:existing_external_upload_key]) if @opts[:existing_external_upload_key]
|
||||||
end
|
end
|
||||||
|
|
||||||
if url.present?
|
if url.present?
|
||||||
|
Loading…
Reference in New Issue
Block a user