]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei import: use url_folder_cache for completion
authorEric Wong <e@80x24.org>
Sat, 12 Jun 2021 00:10:44 +0000 (00:10 +0000)
committerEric Wong <e@80x24.org>
Sun, 13 Jun 2021 17:39:37 +0000 (17:39 +0000)
And fix "lei index" completion while we're at it.

lib/PublicInbox/LeiImport.pm
lib/PublicInbox/LeiIndex.pm

index 08794f711f19cadf264f098fc98f5eb054503899..7580e37e3674a2a0ab1a02a9213d981e80b22315 100644 (file)
@@ -118,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';
index 4be0c649b5cebe8df3d1a4fc336cd4364a9ebdd6..5b545998ba87d6905383d9641e3e32ec159820b4 100644 (file)
@@ -39,7 +39,7 @@ for my $m (qw(pmdir_cb input_net_cb)) {
        *$m = PublicInbox::LeiImport->can($m);
 }
 
-*_complete_import = \&PublicInbox::LeiImport::_complete_import;
+*_complete_index = \&PublicInbox::LeiImport::_complete_import;
 *ipc_atfork_child = \&PublicInbox::LeiInput::input_only_atfork_child;
 *net_merge_all_done = \&PublicInbox::LeiInput::input_only_net_merge_all_done;