about summary refs log tree commit homepage
path: root/lib/PublicInbox
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-10-18 05:09:05 +0000
committerEric Wong <e@80x24.org>2021-10-18 05:15:15 +0000
commit325fbe26c3e7731eb53bea7f2ce2627c8828e0d8 (patch)
tree22a71079d086ce0a7c1a7caffc99eb930123c47f /lib/PublicInbox
parentc51814c647ec83a137be7de3a1baeb7336d318ea (diff)
downloadpublic-inbox-325fbe26c3e7731eb53bea7f2ce2627c8828e0d8.tar.gz
For odd messages with reused Message-IDs, the second message
showing up in a mirror (via git-fetch + -index) should never
clobber an entry with a different blob in over.

This is noticeable only if the messages arrive in-between
indexing runs.

Fixes: 4441a38481ed ("v2: index forwards (via `git log --reverse')")
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r--lib/PublicInbox/V2Writable.pm7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index 3914383c..ed5182ae 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -813,8 +813,8 @@ sub index_oid { # cat_async callback
                         }
                 }
         }
+        my $oidx = $self->{oidx};
         if (!defined($num)) { # reuse if reindexing (or duplicates)
-                my $oidx = $self->{oidx};
                 for my $mid (@$mids) {
                         ($num, $mid0) = $oidx->num_mid0_for_oid($oid, $mid);
                         last if defined $num;
@@ -822,6 +822,11 @@ sub index_oid { # cat_async callback
         }
         $mid0 //= do { # is this a number we got before?
                 $num = $arg->{mm_tmp}->num_for($mids->[0]);
+
+                # don't clobber existing if Message-ID is reused:
+                if (my $x = defined($num) ? $oidx->get_art($num) : undef) {
+                        undef($num) if $x->{blob} ne $oid;
+                }
                 defined($num) ? $mids->[0] : undef;
         };
         if (!defined($num)) {