From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 86EE61FFB0 for ; Tue, 27 Oct 2020 07:54:55 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 13/52] v2writable: count_shards: allow working without {ibx} Date: Tue, 27 Oct 2020 07:54:14 +0000 Message-Id: <20201027075453.19163-14-e@80x24.org> In-Reply-To: <20201027075453.19163-1-e@80x24.org> References: <20201027075453.19163-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 {