From d72ce02b49367927003fa79d9cbb58f12f9d8955 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 27 Oct 2020 07:54:14 +0000 Subject: v2writable: count_shards: allow working without {ibx} 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 { -- cgit v1.2.3-24-ge0c7