Fixed bug: Attachment import RecordNotUnique exception handling fails sometimes.
This commit is contained in:
parent
a286b9e17e
commit
71c7b9d45f
1 changed files with 84 additions and 79 deletions
|
@ -592,6 +592,10 @@ module Import::OTRS
|
|||
}
|
||||
|
||||
record['Articles'].each do |article|
|
||||
|
||||
retries = 3
|
||||
begin
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
|
||||
# get article values
|
||||
|
@ -678,7 +682,6 @@ module Import::OTRS
|
|||
|
||||
filename = Base64.decode64(attachment['Filename'])
|
||||
|
||||
begin
|
||||
Store.add(
|
||||
object: 'Ticket::Article',
|
||||
o_id: article_object.id,
|
||||
|
@ -691,12 +694,14 @@ module Import::OTRS
|
|||
},
|
||||
created_by_id: 1,
|
||||
)
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
log "Ticket #{ticket_new[:id]} (article #{article_object.id}, filename #{filename}) is handled by another thead, skipping."
|
||||
next
|
||||
end
|
||||
}
|
||||
end
|
||||
rescue ActiveRecord::RecordNotUnique => e
|
||||
log "Ticket #{ticket_new[:id]} - RecordNotUnique: #{e}"
|
||||
sleep rand 3
|
||||
retry if !(retries -= 1).zero?
|
||||
raise
|
||||
end
|
||||
end
|
||||
|
||||
#puts "HS: #{record['History'].inspect}"
|
||||
|
|
Loading…
Reference in a new issue