]> Sergey Matveev's repositories - public-inbox.git/commitdiff
content_id: do not take Message-Id into account
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Mon, 19 Mar 2018 23:24:50 +0000 (23:24 +0000)
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Tue, 20 Mar 2018 04:30:55 +0000 (04:30 +0000)
If we need to use content_id, we've already lost hope
in relying on Message-Id as a differentiator.  This
prevents duplicates from showing up repeatedly with
-watch when Message-Ids are reused and we generate
new Message-Ids to disambiguate.

lib/PublicInbox/ContentId.pm
t/v2writable.t

index 9082b7694002168467ab3d2610a36631348116d2..279eec0c1e06f742c2e49a7b91f9f5750b76c0a9 100644 (file)
@@ -21,7 +21,8 @@ sub content_digest ($) {
        # in SearchIdx, so treat them the same for this:
        my %seen;
        foreach my $mid (@{mids($hdr)}) {
-               $dig->add('mid: '.$mid);
+               # do NOT consider the Message-ID as part of the content_id
+               # if we got here, we've already got Message-ID reuse
                $seen{$mid} = 1;
        }
        foreach my $mid (@{references($hdr)}) {
index 85b48d2affff215f01951b67ebdfc9ebb0b8fb15..6cabf0d575b1eac0a22d0549e0792dad7b578054 100644 (file)
@@ -61,11 +61,15 @@ if ('ensure git configs are correct') {
 
        @warn = ();
        $mime->header_set('Message-Id', '<a-mid@b>', '<c@d>');
-       ok($im->add($mime), 'secondary MID used');
+       is($im->add($mime), undef, 'secondary MID ignored if first matches');
+       my $sec = PublicInbox::MIME->new($mime->as_string);
+       $sec->header_set('Date');
+       $sec->header_set('Message-Id', '<a-mid@b>', '<c@d>');
+       ok($im->add($sec), 'secondary MID used if data is different');
        like(join(' ', @warn), qr/mismatched/, 'warned about mismatch');
        like(join(' ', @warn), qr/alternative/, 'warned about alternative');
        is_deeply([ '<a-mid@b>', '<c@d>' ],
-               [ $mime->header_obj->header_raw('Message-Id') ],
+               [ $sec->header_obj->header_raw('Message-Id') ],
                'no new Message-Id added');
 
        my $sane_mid = qr/\A<[\w\-]+\@localhost>\z/;
@@ -85,7 +89,7 @@ if ('ensure git configs are correct') {
        my $gen = PublicInbox::Import::digest2mid(content_digest($mime));
        unlike($gen, qr![\+/=]!, 'no URL-unfriendly chars in Message-Id');
        my $fake = PublicInbox::MIME->new($mime->as_string);
-       $fake->header_set('Message-Id', $gen);
+       $fake->header_set('Message-Id', "<$gen>");
        ok($im->add($fake), 'fake added easily');
        is_deeply(\@warn, [], 'no warnings from a faker');
        ok($im->add($mime), 'random MID made');