]> Sergey Matveev's repositories - public-inbox.git/blob - lib/PublicInbox/LeiIndex.pm
imap+nntp: share COMPRESS implementation
[public-inbox.git] / lib / PublicInbox / LeiIndex.pm
1 # Copyright (C) 2021 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3
4 # front-end for the "lei index" sub-command, this is similar to
5 # "lei import" but doesn't put a git blob into ~/.local/share/lei/store
6 package PublicInbox::LeiIndex;
7 use strict;
8 use v5.10.1;
9 use parent qw(PublicInbox::IPC PublicInbox::LeiInput);
10 use PublicInbox::LeiImport;
11
12 # /^input_/ subs are used by (or override) PublicInbox::LeiInput superclass
13 sub input_eml_cb { # used by input_maildir_cb and input_net_cb
14         my ($self, $eml, $vmd) = @_;
15         my $xoids = $self->{lei}->{ale}->xoids_for($eml);
16         if (my $all_vmd = $self->{all_vmd}) {
17                 @$vmd{keys %$all_vmd} = values %$all_vmd;
18         }
19         $self->{lei}->{sto}->wq_do('index_eml_only', $eml, $vmd, $xoids);
20 }
21
22 sub input_fh { # overrides PublicInbox::LeiInput::input_fh
23         my ($self, $ifmt, $fh, $input, @args) = @_;
24         $self->{lei}->child_error(0, <<EOM);
25 $input ($ifmt) not yet supported, try `lei import'
26 EOM
27 }
28
29 sub lei_index {
30         my ($lei, @argv) = @_;
31         $lei->{opt}->{'mail-sync'} = 1;
32         my $self = bless {}, __PACKAGE__;
33         PublicInbox::LeiImport::do_import_index($self, $lei, @argv);
34 }
35
36 no warnings 'once';
37 no strict 'refs';
38 for my $m (qw(pmdir_cb input_net_cb)) {
39         *$m = PublicInbox::LeiImport->can($m);
40 }
41
42 *_complete_index = \&PublicInbox::LeiImport::_complete_import;
43 *ipc_atfork_child = \&PublicInbox::LeiInput::input_only_atfork_child;
44 *net_merge_all_done = \&PublicInbox::LeiInput::input_only_net_merge_all_done;
45
46 1;