]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Search.pm
v2writable: reuse read-only shard counting code
[public-inbox.git] / lib / PublicInbox / Search.pm
index cfa942b2f75a794f3ed356bf743b7799b86dca72..fb35b74752c88531fe3ad0c2c8774dcf598d1b38 100644 (file)
@@ -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);
@@ -265,8 +268,6 @@ sub new {
                ibx_ver => $ibx->version,
        }, $class;
        xpfx_init($self);
-       my $dir = xdir($self, 1);
-       $self->{over_ro} = PublicInbox::Over->new("$dir/over.sqlite3");
        $self;
 }