about summary refs log tree commit homepage
path: root/lib/PublicInbox/Msgmap.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2017-06-22 19:51:23 +0000
committerEric Wong <e@80x24.org>2017-06-22 19:51:23 +0000
commit1e57ecc0dcbc64a6829a93dc81cfb6ab6f0ce71b (patch)
tree3e50a1ab44a1229895710d5212e4c3722af985a7 /lib/PublicInbox/Msgmap.pm
parent9b80f2bedbe5a8a9154dfa0ba3c7e63012287bea (diff)
downloadpublic-inbox-1e57ecc0dcbc64a6829a93dc81cfb6ab6f0ce71b.tar.gz
This will allow smoother imports as occasional Message-ID
duplicates happen and the best we can do is ignore the
second one.
Diffstat (limited to 'lib/PublicInbox/Msgmap.pm')
-rw-r--r--lib/PublicInbox/Msgmap.pm6
1 files changed, 3 insertions, 3 deletions
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');
 }