about summary refs log tree commit homepage
path: root/lib/PublicInbox/Search.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-09-02 11:04:21 +0000
committerEric Wong <e@80x24.org>2020-09-03 20:11:03 +0000
commit3bf9e1e4d8e5a84a0d8c733faf49555aa84379aa (patch)
tree2dbb5afc9c71cc7ab6c306472161f7e8f08806c0 /lib/PublicInbox/Search.pm
parent12d219222ac5bc09cf364f15834c1e5cc5659e8f (diff)
downloadpublic-inbox-3bf9e1e4d8e5a84a0d8c733faf49555aa84379aa.tar.gz
We'll also fix the read-only code to ensure we notice missing
Xapian shards, since gaps would throw off our expectation that
Xapian document IDs and NNTP article numbers are interchangeable.
Diffstat (limited to 'lib/PublicInbox/Search.pm')
-rw-r--r--lib/PublicInbox/Search.pm5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index b07f4ea6..fb35b747 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -7,6 +7,7 @@ package PublicInbox::Search;
 use strict;
 use parent qw(Exporter);
 our @EXPORT_OK = qw(mdocid);
+use List::Util qw(max);
 
 # values for searching, changing the numeric value breaks
 # compatibility with old indices (so don't change them it)
@@ -203,7 +204,9 @@ sub _xdb ($) {
 
                 # We need numeric sorting so shard[0] is first for reading
                 # Xapian metadata, if needed
-                for (sort { $a <=> $b } grep(/\A[0-9]+\z/, readdir($dh))) {
+                my $last = max(grep(/\A[0-9]+\z/, readdir($dh)));
+                return if !defined($last);
+                for (0..$last) {
                         my $shard_dir = "$dir/$_";
                         if (-d $shard_dir && -r _) {
                                 push @xdb, $X{Database}->new($shard_dir);