about summary refs log tree commit homepage
path: root/lib/PublicInbox/V2Writable.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/V2Writable.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/V2Writable.pm')
-rw-r--r--lib/PublicInbox/V2Writable.pm23
1 files changed, 3 insertions, 20 deletions
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index c8334645..a1f6048f 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -65,28 +65,11 @@ sub nproc_shards ($) {
 
 sub count_shards ($) {
         my ($self) = @_;
-        my $n = 0;
-        my $xpfx = $self->{xpfx};
-
         # always load existing shards in case core count changes:
         # Also, shard count may change while -watch is running
-        # due to "xcpdb --reshard"
-        if (-d $xpfx) {
-                my $XapianDatabase;
-                foreach my $shard (<$xpfx/*>) {
-                        -d $shard && $shard =~ m!/[0-9]+\z! or next;
-                        $XapianDatabase //= do {
-                                require PublicInbox::Search;
-                                PublicInbox::Search::load_xapian();
-                                $PublicInbox::Search::X{Database};
-                        };
-                        eval {
-                                $XapianDatabase->new($shard)->close;
-                                $n++;
-                        };
-                }
-        }
-        $n;
+        my $srch = $self->{ibx}->search or return 0;
+        delete $self->{ibx}->{search};
+        $srch->{nshard} // 0
 }
 
 sub new {