]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/V2Writable.pm
nntp: attempt RFC 5536 3.1.5-conformant Path: headers
[public-inbox.git] / lib / PublicInbox / V2Writable.pm
index c8334645d3cbcff5bf0b290bda75db7bd8113022..c04f0c5951495754da74061c79456ac14b9c8f8e 100644 (file)
@@ -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 {
@@ -1047,7 +1030,7 @@ sub sync_prepare ($$$) {
        my ($self, $sync, $epoch_max) = @_;
        my $pr = $sync->{-opt}->{-progress};
        my $regen_max = 0;
-       my $head = $self->{ibx}->{ref_head} || 'refs/heads/master';
+       my $head = $self->{ibx}->{ref_head} || 'HEAD';
 
        # reindex stops at the current heads and we later rerun index_sync
        # without {reindex}
@@ -1091,7 +1074,7 @@ sub sync_prepare ($$$) {
                }
                $all->cat_async_wait;
        }
-       if (!$regen_max && !keys(%{$self->{unindex_range}})) {
+       if (!$regen_max) {
                $sync->{-regen_fmt} = "%u/?\n";
                return 0;
        }
@@ -1245,8 +1228,7 @@ sub index_epoch ($$$) {
                        reindex_checkpoint($self, $sync);
                }
        }
-       $all->check_async_wait;
-       $all->cat_async_wait;
+       $all->async_wait_all;
        update_last_commit($self, $git, $i, $stk->{latest_cmt});
 }
 
@@ -1284,8 +1266,8 @@ sub xapian_only {
 # public, called by public-inbox-index
 sub index_sync {
        my ($self, $opt) = @_;
-       $opt //= $_[1] //= {};
-       goto \&xapian_only if $opt->{xapian_only};
+       $opt //= {};
+       return xapian_only($self, $opt) if $opt->{xapian_only};
 
        my $pr = $opt->{-progress};
        my $epoch_max;