]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiImport.pm
lei index: new command to index mail w/o git storage
[public-inbox.git] / lib / PublicInbox / LeiImport.pm
index def121abbe5b8fd53cdd0fa342ae4a23915d7c21..55925cc5ae7287093190927fe43185cbaf6cdb88 100644 (file)
@@ -38,27 +38,20 @@ sub input_maildir_cb { # maildir_each_eml cb
                        warn "E: $f was not from a Maildir?\n";
                }
        }
-       input_eml_cb($self, $eml, $vmd);
+       $self->input_eml_cb($eml, $vmd);
 }
 
 sub input_net_cb { # imap_each / nntp_each
        my ($url, $uid, $kw, $eml, $self) = @_;
        my $vmd = $self->{-import_kw} ? { kw => $kw } : undef;
        $vmd->{sync_info} = [ $url, $uid ] if $self->{-mail_sync};
-       input_eml_cb($self, $eml, $vmd);
-}
-
-sub net_merge_complete { # callback used by LeiAuth
-       my ($self) = @_;
-       $self->wq_io_do('process_inputs');
-       $self->wq_close(1);
+       $self->input_eml_cb($eml, $vmd);
 }
 
-sub lei_import { # the main "lei import" method
-       my ($lei, @inputs) = @_;
+sub do_import_index ($$@) {
+       my ($self, $lei, @inputs) = @_;
        my $sto = $lei->_lei_store(1);
        $sto->write_prepare($lei);
-       my $self = bless {}, __PACKAGE__;
        $self->{-import_kw} = $lei->{opt}->{kw} // 1;
        my $vmd_mod = $self->vmd_mod_extract(\@inputs);
        return $lei->fail(join("\n", @{$vmd_mod->{err}})) if $vmd_mod->{err};
@@ -82,13 +75,19 @@ sub lei_import { # the main "lei import" method
        $lei->{auth}->op_merge($ops, $self) if $lei->{auth};
        $self->{-wq_nr_workers} = $j // 1; # locked
        $lei->{-eml_noisy} = 1;
-       (my $op_c, $ops) = $lei->workers_start($self, 'lei-import', $j, $ops);
+       (my $op_c, $ops) = $lei->workers_start($self, $j, $ops);
        $lei->{wq1} = $self;
        $lei->{-err_type} = 'non-fatal';
-       net_merge_complete($self) unless $lei->{auth};
+       net_merge_all_done($self) unless $lei->{auth};
        $op_c->op_wait_event($ops);
 }
 
+sub lei_import { # the main "lei import" method
+       my ($lei, @inputs) = @_;
+       my $self = bless {}, __PACKAGE__;
+       do_import_index($self, $lei, @inputs);
+}
+
 sub _complete_import {
        my ($lei, @argv) = @_;
        my $sto = $lei->_lei_store or return;
@@ -99,6 +98,7 @@ sub _complete_import {
 
 no warnings 'once';
 *ipc_atfork_child = \&PublicInbox::LeiInput::input_only_atfork_child;
+*net_merge_all_done = \&PublicInbox::LeiInput::input_only_net_merge_all_done;
 
 # the following works even when LeiAuth is lazy-loaded
 *net_merge_all = \&PublicInbox::LeiAuth::net_merge_all;