about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-09-21 07:41:56 +0000
committerEric Wong <e@80x24.org>2021-09-21 19:18:36 +0000
commit702864ea3393f4c7a91336b277083bf9fd4b0860 (patch)
tree369699e68c25b43c7a0c616753273c5619a150cf /lib
parent8b91bd5f929bf166ee3a79dec43fba0e68b1dc8e (diff)
downloadpublic-inbox-702864ea3393f4c7a91336b277083bf9fd4b0860.tar.gz
lei q: show progress on >1s preparation phase
Overwriting existing destinations safe (but slow) by default,
so show a progress message noting what we're doing while
a user waits.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/LeiToMail.pm23
-rw-r--r--lib/PublicInbox/LeiXSearch.pm2
2 files changed, 23 insertions, 2 deletions
diff --git a/lib/PublicInbox/LeiToMail.pm b/lib/PublicInbox/LeiToMail.pm
index a419b83f..ed609081 100644
--- a/lib/PublicInbox/LeiToMail.pm
+++ b/lib/PublicInbox/LeiToMail.pm
@@ -689,6 +689,8 @@ sub do_augment { # slow, runs in wq worker
 # fast (spawn compressor or mkdir), runs in same process as pre_augment
 sub post_augment {
         my ($self, $lei, @args) = @_;
+        $self->{-au_noted}++ and $lei->qerr("# writing to $self->{dst} ...");
+
         my $wait = $lei->{opt}->{'import-before'} ?
                         $lei->{sto}->wq_do('checkpoint', 1) : 0;
         # _post_augment_mbox
@@ -784,9 +786,28 @@ sub wq_atexit_child {
         $lei->{pkt_op_p}->pkt_do('l2m_progress', $nr);
 }
 
+# runs on a 1s timer in lei-daemon
+sub augment_inprogress {
+        my ($err, $opt, $dst, $au_noted) = @_;
+        $$au_noted++ and return;
+        print $err '# '.($opt->{'import-before'} ?
+                        "importing non-external contents of $dst" : (
+                        ($opt->{dedupe} // 'content') ne 'none') ?
+                        "scanning old contents of $dst for dedupe" :
+                        "removing old contents of $dst")." ...\n";
+}
+
 # called in top-level lei-daemon when LeiAuth is done
 sub net_merge_all_done {
-        my ($self) = @_;
+        my ($self, $lei) = @_;
+        if ($PublicInbox::DS::in_loop &&
+                        $self->can("_do_augment_$self->{base_type}") &&
+                        !$lei->{opt}->{quiet}) {
+                $self->{-au_noted} = 0;
+                PublicInbox::DS::add_timer(1, \&augment_inprogress,
+                                $lei->{2}, $lei->{opt},
+                                $self->{dst}, \$self->{-au_noted});
+        }
         $self->wq_broadcast('do_post_auth');
         $self->wq_close(1);
 }
diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm
index 3ce8f32d..2227c2ac 100644
--- a/lib/PublicInbox/LeiXSearch.pm
+++ b/lib/PublicInbox/LeiXSearch.pm
@@ -572,7 +572,7 @@ sub do_query {
         $self->{opt_sort} = $lei->{opt}->{'sort'};
         $self->{-do_lcat} = !!(delete $lei->{lcat_todo});
         if ($l2m) {
-                $l2m->net_merge_all_done unless $lei->{auth};
+                $l2m->net_merge_all_done($lei) unless $lei->{auth};
         } else {
                 start_query($self);
         }