It's possible to update the fingerprint for a given repo when we
have no commits to index on because they were already done for
another repo.  Thus we'll always vivify $repo_ctx->{active}
before calling store_repo since $active may've been undef.
---
 lib/PublicInbox/CodeSearchIdx.pm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/PublicInbox/CodeSearchIdx.pm b/lib/PublicInbox/CodeSearchIdx.pm
index 7d696099..bd67a57e 100644
--- a/lib/PublicInbox/CodeSearchIdx.pm
+++ b/lib/PublicInbox/CodeSearchIdx.pm
@@ -613,14 +613,14 @@ sub next_repos { # OnDestroy cb
 
 sub index_done { # OnDestroy cb called when done indexing each code repo
        my ($repo_ctx, $drs) = @_;
-       my ($self, $repo, $active) = @$repo_ctx{qw(self repo active)};
-
        return if $DO_QUIT;
+       my ($self, $repo, $active) = @$repo_ctx{qw(self repo active)};
+       # $active may be undef here, but it's fine to vivify
        my $n = grep { ! $repo_ctx->{shard_ok}->{$_} } keys %$active;
        die "E: $repo->{git_dir} $n shards failed" if $n;
        $repo_ctx->{shard_ok} = {}; # reset for future shard_done
        $n = $repo->{shard_n};
-       $active->{$n} = undef;
+       $repo_ctx->{active}->{$n} = undef; # may vivify $repo_ctx->{active}
        my ($c, $p) = PublicInbox::PktOp->pair;
        $c->{ops}->{repo_stored} = [ $self, $repo_ctx, $drs ];
        $IDX_SHARDS[$n]->wq_io_do('store_repo', [ $p->{op_p} ], $repo);

Reply via email to