]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
cindex: fix store_repo+repo_stored on no-op
authorEric Wong <e@80x24.org>
Thu, 30 Nov 2023 11:40:54 +0000 (11:40 +0000)
committerEric Wong <e@80x24.org>
Thu, 30 Nov 2023 21:36:48 +0000 (21:36 +0000)
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

index 7d6960996e3c69c1a51512685b254c523cf1e0bf..bd67a57ed97439f825e2861aead50b42b8e1f250 100644 (file)
@@ -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);