mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-22 17:38:07 +01:00
Fix and improve batch attachment deletion handling when using OpenStack Swift (#32637)
This commit is contained in:
parent
dc0b1948be
commit
b1d3c64525
1 changed files with 14 additions and 2 deletions
|
@ -77,10 +77,22 @@ class AttachmentBatch
|
||||||
when :fog
|
when :fog
|
||||||
logger.debug { "Deleting #{attachment.path(style)}" }
|
logger.debug { "Deleting #{attachment.path(style)}" }
|
||||||
|
|
||||||
|
retries = 0
|
||||||
begin
|
begin
|
||||||
attachment.send(:directory).files.new(key: attachment.path(style)).destroy
|
attachment.send(:directory).files.new(key: attachment.path(style)).destroy
|
||||||
rescue Fog::Storage::OpenStack::NotFound
|
rescue Fog::OpenStack::Storage::NotFound
|
||||||
# Ignore failure to delete a file that has already been deleted
|
logger.debug "Will ignore because file is not found #{attachment.path(style)}"
|
||||||
|
rescue => e
|
||||||
|
retries += 1
|
||||||
|
|
||||||
|
if retries < MAX_RETRY
|
||||||
|
logger.debug "Retry #{retries}/#{MAX_RETRY} after #{e.message}"
|
||||||
|
sleep 2**retries
|
||||||
|
retry
|
||||||
|
else
|
||||||
|
logger.error "Batch deletion from fog failed after #{e.message}"
|
||||||
|
raise e
|
||||||
|
end
|
||||||
end
|
end
|
||||||
when :azure
|
when :azure
|
||||||
logger.debug { "Deleting #{attachment.path(style)}" }
|
logger.debug { "Deleting #{attachment.path(style)}" }
|
||||||
|
|
Loading…
Reference in a new issue