This will be needed for ExtSearchIdx which doesn't have a
persistent PublicInbox::Inbox object.
---
 lib/PublicInbox/V2Writable.pm | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index f575ba11..667a11f8 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -65,11 +65,13 @@ sub nproc_shards ($) {
 
 sub count_shards ($) {
        my ($self) = @_;
-       # always load existing shards in case core count changes:
-       # Also, shard count may change while -watch is running
-       my $srch = $self->{ibx}->search or return 0;
-       delete $self->{ibx}->{search};
-       $srch->{nshard} // 0
+       $self->{ibx} ? do {
+               # always load existing shards in case core count changes:
+               # Also, shard count may change while -watch is running
+               my $srch = $self->{ibx}->search or return 0;
+               delete $self->{ibx}->{search};
+               $srch->{nshard} // 0
+       } : $self->{nshard}; # self->{nshard} is for ExtSearchIdx
 }
 
 sub new {
--
unsubscribe: one-click, see List-Unsubscribe header
archive: https://public-inbox.org/meta/

Reply via email to