From 738069dfba22c2e44a6ae2d66dee3a958f9da4b3 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Fri, 24 Jul 2015 12:17:42 +0200 Subject: [PATCH] Made article creation thread safe. --- lib/import/otrs.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/import/otrs.rb b/lib/import/otrs.rb index 3ecffea51..7186f8602 100644 --- a/lib/import/otrs.rb +++ b/lib/import/otrs.rb @@ -652,9 +652,14 @@ module Import::OTRS article_object.update_attributes(article_new) else log "add Ticket::Article.find(#{article_new[:id]})" - article_object = Ticket::Article.new(article_new) - article_object.id = article_new[:id] - article_object.save + begin + article_object = Ticket::Article.new(article_new) + article_object.id = article_new[:id] + article_object.save + rescue ActiveRecord::RecordNotUnique + log "Ticket #{ticket_new[:id]} (article #{article_new[:id]}) is handled by another thead, skipping." + next + end end next if !article['Attachments']