diff --git a/app/models/list_import.rb b/app/models/list_import.rb index f32dd3f78..5808efacf 100644 --- a/app/models/list_import.rb +++ b/app/models/list_import.rb @@ -42,12 +42,14 @@ def apply Chewy.strategy(:atomic) do each_with_index do |(media, data), index| next if media.blank? - # Merge the library entries - le = LibraryEntry.where(user_id: user.id, media:).first_or_initialize - le.imported = true - le = merged_entry(le, data) - le.save! unless le.status.nil? - yield({ status: :running, total:, progress: index + 1 }) + Retriable.retriable on: [ActiveRecord::RecordNotUnique] do + # Merge the library entries + le = LibraryEntry.where(user_id: user.id, media:).first_or_initialize + le.imported = true + le = merged_entry(le, data) + le.save! unless le.status.nil? + yield({ status: :running, total:, progress: index + 1 }) + end rescue StandardError => e Sentry.capture_exception(e) yield({