about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2017-06-24 22:26:28 +0000
committerEric Wong <e@80x24.org>2017-06-26 03:44:35 +0000
commit8b0359338d1ec1e0ec7521c77b35f878931f4cd6 (patch)
tree4c0424a1e7cb130c5f5b1d36bf8023357315286a /lib
parentf9b70eb6ebbf96c2fe79ab2738ea4954c5a124f3 (diff)
downloadpublic-inbox-8b0359338d1ec1e0ec7521c77b35f878931f4cd6.tar.gz
This should be more reliable and safer as it'll ensure
existing fast-import instances are shut down properly.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/WatchMaildir.pm12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm
index 0e2a6d2c..5e79bb50 100644
--- a/lib/PublicInbox/WatchMaildir.pm
+++ b/lib/PublicInbox/WatchMaildir.pm
@@ -201,7 +201,7 @@ sub _try_path {
         $im->add($mime, $self->{spamcheck});
 }
 
-sub quit { $_[0]->{quit} = 1 }
+sub quit { trigger_scan($_[0], 'quit') }
 
 sub watch {
         my ($self) = @_;
@@ -215,7 +215,7 @@ sub watch {
         # in the future...
         require Filesys::Notify::Simple;
         my $fsn = Filesys::Notify::Simple->new([@{$self->{mdir}}, $scandir]);
-        $fsn->wait($cb) until ($self->{quit});
+        $fsn->wait($cb) until $self->{quit};
 }
 
 sub trigger_scan {
@@ -227,6 +227,14 @@ sub trigger_scan {
 
 sub scan {
         my ($self, $path) = @_;
+        if ($path =~ /quit\z/) {
+                %{$self->{opendirs}} = ();
+                _done_for_now($self);
+                $self->{quit} = 1;
+                return;
+        }
+        # else: $path =~ /(cont|full)\z/
+        return if $self->{quit};
         my $max = 10;
         my $opendirs = $self->{opendirs};
         my @dirnames = keys %$opendirs;