]> Sergey Matveev's repositories - public-inbox.git/commitdiff
v2writable: count_shards: allow working without {ibx}
authorEric Wong <e@80x24.org>
Tue, 27 Oct 2020 07:54:14 +0000 (07:54 +0000)
committerEric Wong <e@80x24.org>
Sat, 7 Nov 2020 10:18:43 +0000 (10:18 +0000)
This will be needed for ExtSearchIdx which doesn't have a
persistent PublicInbox::Inbox object.

lib/PublicInbox/V2Writable.pm

index f575ba111580508c45ed1fac51d35ea7ad046e1a..667a11f833ca1b63e3f5e15a22d4e76108eb22b2 100644 (file)
@@ -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 {