]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiImport.pm
www: avoid incorrect instructions for extindex
[public-inbox.git] / lib / PublicInbox / LeiImport.pm
index e3cb69ca93d44bf878d573e19b81fc5b833c1941..7580e37e3674a2a0ab1a02a9213d981e80b22315 100644 (file)
@@ -78,12 +78,14 @@ sub do_import_index ($$@) {
        $j =~ /\A([0-9]+),[0-9]+\z/ and $j = $1 + 0;
        $j ||= scalar(@{$self->{inputs}}) || 1;
        my $ikw;
-       if (my $net = $lei->{net}) {
+       my $net = $lei->{net};
+       if ($net) {
                # $j = $net->net_concurrency($j); TODO
                if ($lei->{opt}->{incremental} // 1) {
                        $net->{incremental} = 1;
                        $net->{-lms_ro} = $sto->search->lms // 0;
                        if ($self->{-import_kw} && $net->{-lms_ro} &&
+                                       !$lei->{opt}->{'new-only'} &&
                                        $net->{imap_order}) {
                                require PublicInbox::LeiImportKw;
                                $ikw = PublicInbox::LeiImportKw->new($lei);
@@ -94,6 +96,9 @@ sub do_import_index ($$@) {
                my $nproc = $self->detect_nproc;
                $j = $nproc if $j > $nproc;
        }
+       if ($lei->{opt}->{'new-only'} && (!$net || !$net->{imap_order})) {
+               $lei->err('# --new-only is only for IMAP');
+       }
        my $ops = {};
        $lei->{auth}->op_merge($ops, $self) if $lei->{auth};
        $self->{-wq_nr_workers} = $j // 1; # locked
@@ -113,10 +118,15 @@ sub lei_import { # the main "lei import" method
 
 sub _complete_import {
        my ($lei, @argv) = @_;
-       my $sto = $lei->_lei_store or return;
-       my $lms = $sto->search->lms or return;
        my $match_cb = $lei->complete_url_prepare(\@argv);
-       map { $match_cb->($_) } $lms->folders;
+       my @m = map { $match_cb->($_) } $lei->url_folder_cache->keys;
+       my %f = map { $_ => 1 } @m;
+       my $sto = $lei->_lei_store;
+       if (my $lms = $sto ? $sto->search->lms : undef) {
+               @m = map { $match_cb->($_) } $lms->folders;
+               @f{@m} = @m;
+       }
+       keys %f;
 }
 
 no warnings 'once';