From 080ddbb0d3091282879a54515b5927801ee12952 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 26 Jun 2017 02:56:03 +0000 Subject: [PATCH] watch: commit changes to fast-import sooner We should make changes visible sooner, even during lengthy scans. --- lib/PublicInbox/WatchMaildir.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm index 5e79bb50..8e10e43f 100644 --- a/lib/PublicInbox/WatchMaildir.pm +++ b/lib/PublicInbox/WatchMaildir.pm @@ -91,13 +91,18 @@ sub new { sub _done_for_now { my ($self) = @_; + my $importers = $self->{importers}; + foreach my $im (values %$importers) { + $im->done if $im->{nchg}; + } + my $opendirs = $self->{opendirs}; # spamdir scanning means every importer remains open my $spamdir = $self->{spamdir}; return if defined($spamdir) && $opendirs->{$spamdir}; - foreach my $im (values %{$self->{importers}}) { + foreach my $im (values %$importers) { # not done if we're scanning next if $opendirs->{$im->{git}->{git_dir}}; $im->done; @@ -263,11 +268,9 @@ sub scan { $opendirs->{$dir} = $dh if $n < 0; } } - if (keys %$opendirs) { # do we have more work to do? - trigger_scan($self, 'cont'); - } else { - _done_for_now($self); - } + _done_for_now($self); + # do we have more work to do? + trigger_scan($self, 'cont') if keys %$opendirs; } sub _path_to_mime { -- 2.44.0