Skip to content
Snippets Groups Projects
Commit dd0992b2 authored by Hugo Gameiro's avatar Hugo Gameiro Committed by Claire
Browse files

Fix and improve batch attachment deletion handling when using OpenStack Swift (#32637)

parent 9b677f09
No related branches found
No related tags found
No related merge requests found
......@@ -77,10 +77,22 @@ class AttachmentBatch
when :fog
logger.debug { "Deleting #{attachment.path(style)}" }
retries = 0
begin
attachment.send(:directory).files.new(key: attachment.path(style)).destroy
rescue Fog::Storage::OpenStack::NotFound
# Ignore failure to delete a file that has already been deleted
rescue Fog::OpenStack::Storage::NotFound
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
when :azure
logger.debug { "Deleting #{attachment.path(style)}" }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment