1 # Copyright all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 # "lei reindex" command to reindex everything in lei/store
5 package PublicInbox::LeiReindex;
7 use parent qw(PublicInbox::IPC);
11 my $sto = $lei->{sto};
12 my $max = $sto->search->over(1)->max;
13 $lei->qerr("# reindexing 1..$max");
14 $sto->wq_do('reindex_art', $_) for (1..$max);
17 sub reindex_store { # via wq_do
19 my ($lei, $argv) = delete @$self{qw(lei argv)};
26 my ($lei, @argv) = @_;
27 my $sto = $lei->_lei_store or return $lei->fail('nothing indexed');
28 $sto->write_prepare($lei);
29 my $self = bless { lei => $lei, argv => \@argv }, __PACKAGE__;
30 my ($op_c, $ops) = $lei->workers_start($self, 1);
32 $lei->wait_wq_events($op_c, $ops);
33 $self->wq_do('reindex_store');
37 sub _lei_wq_eof { # EOF callback for main lei daemon
39 $lei->{sto}->wq_do('reindex_done');
43 sub ipc_atfork_child {
45 $self->{lei}->_lei_atfork_child;
46 $self->SUPER::ipc_atfork_child;