mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 12:51:24 +08:00
FIX: skip upload recovery if file not found in s3
This commit is contained in:
@ -85,6 +85,7 @@ class S3Inventory
|
|||||||
result = connection.exec("SELECT * FROM #{table_name} WHERE key LIKE '%original/%/#{sha1}%'")
|
result = connection.exec("SELECT * FROM #{table_name} WHERE key LIKE '%original/%/#{sha1}%'")
|
||||||
|
|
||||||
if result.count >= 1
|
if result.count >= 1
|
||||||
|
begin
|
||||||
key = result[0]["key"]
|
key = result[0]["key"]
|
||||||
data = @s3_helper.object(key).data
|
data = @s3_helper.object(key).data
|
||||||
filename = (data.content_disposition&.match(/filename=\"(.*)\"/) || [])[1]
|
filename = (data.content_disposition&.match(/filename=\"(.*)\"/) || [])[1]
|
||||||
@ -99,6 +100,9 @@ class S3Inventory
|
|||||||
)
|
)
|
||||||
upload.save!(validate: false)
|
upload.save!(validate: false)
|
||||||
upload_id = upload.id
|
upload_id = upload.id
|
||||||
|
rescue Aws::S3::Errors::NotFound
|
||||||
|
next
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
upload_id
|
upload_id
|
||||||
|
Reference in New Issue
Block a user