]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/ExtMsg.pm
s/news.gmane.org/news.gmane.io/
[public-inbox.git] / lib / PublicInbox / ExtMsg.pm
index 0138d373cbea417d9318eaf974ade6745c983b9e..e6a872d9dc36e86ac38cadbf5f2f8a92993e7ccc 100644 (file)
@@ -8,8 +8,7 @@
 package PublicInbox::ExtMsg;
 use strict;
 use warnings;
-use PublicInbox::Hval qw/ascii_html/;
-use PublicInbox::MID qw/mid2path/;
+use PublicInbox::Hval qw(ascii_html prurl);
 use PublicInbox::WwwStream;
 our $MIN_PARTIAL_LEN = 16;
 
@@ -18,7 +17,7 @@ our @EXT_URL = map { ascii_html($_) } (
        # leading "//" denotes protocol-relative (http:// or https://)
        '//marc.info/?i=%s',
        '//www.mail-archive.com/search?l=mid&q=%s',
-       'nntp://news.gmane.org/%s',
+       'nntp://news.gmane.io/%s',
        'https://lists.debian.org/msgid-search/%s',
        '//docs.FreeBSD.org/cgi/mid.cgi?db=mid&id=%s',
        'https://www.w3.org/mid/%s',
@@ -29,6 +28,10 @@ our @EXT_URL = map { ascii_html($_) } (
 
 sub PARTIAL_MAX () { 100 }
 
+sub mids_from_mset { # Search::retry_reopen callback
+       [ map { PublicInbox::SearchMsg::from_mitem($_)->mid } $_[0]->items ];
+}
+
 sub search_partial ($$) {
        my ($srch, $mid) = @_;
        return if length($mid) < $MIN_PARTIAL_LEN;
@@ -65,12 +68,8 @@ sub search_partial ($$) {
                # Search::Xapian::QueryParserError or even:
                # "something terrible happened at ../Search/Xapian/Enquire.pm"
                my $mset = eval { $srch->query($m, $opt) } or next;
-
-               my @mids = map {
-                       my $doc = $_->get_document;
-                       PublicInbox::SearchMsg->load_doc($doc)->mid;
-               } $mset->items;
-               return \@mids if scalar(@mids);
+               my $mids = $srch->retry_reopen(\&mids_from_mset, $mset);
+               return $mids if scalar(@$mids);
        }
 }
 
@@ -172,7 +171,7 @@ sub ext_urls {
                my $env = $ctx->{env};
                my $e = "\nPerhaps try an external site:\n\n";
                foreach my $url (@EXT_URL) {
-                       my $u = PublicInbox::Hval::prurl($env, $url);
+                       my $u = prurl($env, $url);
                        my $r = sprintf($u, $href);
                        my $t = sprintf($u, $html);
                        $e .= qq{<a\nhref="$r">$t</a>\n};