]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lookup by Message-ID favors the "primary" one
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Thu, 29 Mar 2018 09:57:46 +0000 (09:57 +0000)
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Thu, 29 Mar 2018 09:59:57 +0000 (09:59 +0000)
The Message-ID mapped to an NNTP article number is stronger,
so we will favor that for attachment lookups.

lib/PublicInbox/Inbox.pm

index 47b863094bae63964ff97afc84657473e5c8c75f..4c7305f96dfa041710987697fc4a2dc76eba8549 100644 (file)
@@ -298,9 +298,15 @@ sub msg_by_mid ($$;$) {
        my $srch = search($self) or
                        return msg_by_path($self, mid2path($mid), $ref);
        my $smsg;
-       $srch->retry_reopen(sub {
-               $smsg = $srch->lookup_skeleton($mid) and $smsg->load_expand;
-       });
+       # favor the Message-ID we used for the NNTP article number:
+       if (my $mm = mm($self)) {
+               my $num = $mm->num_for($mid);
+               $smsg = $srch->lookup_article($num);
+       } else {
+               $smsg = $srch->retry_reopen(sub {
+                       $srch->lookup_skeleton($mid) and $smsg->load_expand;
+               });
+       }
        $smsg ? msg_by_smsg($self, $smsg, $ref) : undef;
 }