From 1e57ecc0dcbc64a6829a93dc81cfb6ab6f0ce71b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 22 Jun 2017 19:51:23 +0000 Subject: msgmap: mid_insert ignores duplicates instead of die-ing This will allow smoother imports as occasional Message-ID duplicates happen and the best we can do is ignore the second one. --- lib/PublicInbox/Msgmap.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/PublicInbox/Msgmap.pm') diff --git a/lib/PublicInbox/Msgmap.pm b/lib/PublicInbox/Msgmap.pm index 3fb3805f..a49b61e8 100644 --- a/lib/PublicInbox/Msgmap.pm +++ b/lib/PublicInbox/Msgmap.pm @@ -82,10 +82,10 @@ sub created_at { sub mid_insert { my ($self, $mid) = @_; my $dbh = $self->{dbh}; - use constant MID_INSERT => 'INSERT INTO msgmap (mid) VALUES (?)'; - my $sth = $self->{mid_insert} ||= $dbh->prepare(MID_INSERT); + my $sql = 'INSERT OR IGNORE INTO msgmap (mid) VALUES (?)'; + my $sth = $self->{mid_insert} ||= $dbh->prepare($sql); $sth->bind_param(1, $mid); - $sth->execute; + return if $sth->execute == 0; $dbh->last_insert_id(undef, undef, 'msgmap', 'num'); } -- cgit v1.2.3-24-ge0c7