]> Sergey Matveev's repositories - public-inbox.git/commitdiff
import: auto-update index when done
authorEric Wong <e@80x24.org>
Fri, 17 Jun 2016 01:56:05 +0000 (01:56 +0000)
committerEric Wong <e@80x24.org>
Fri, 17 Jun 2016 01:57:26 +0000 (01:57 +0000)
This prevents multiple update processes from stepping over
each other while called under the lock, and also allows the
new -watch process to update the index iff indexing was
desired.

lib/PublicInbox/Import.pm
script/public-inbox-learn
script/public-inbox-mda

index e3d65f4aa73b8eb28fa3e9024361c057e2284b9c..c13d4834992b57eb9c5dbcc81b356d84749d2753 100644 (file)
@@ -226,6 +226,11 @@ sub done {
                waitpid($pid, 0) == $pid or
                        die 'update-server-info did not finish';
                $? == 0 or die "failed to update-server-info: $?\n";
+
+               eval {
+                       require PublicInbox::SearchIdx;
+                       PublicInbox::SearchIdx->new($git_dir, 2)->index_sync;
+               };
        }
 
        my $lockfh = delete $self->{lockfh} or die "BUG: not locked: $!";
index 817fd5e9ca1f5f9f47ff7b1c1fdde96103f1e2ea..b05ef05687dd446810be229e5fd1e59ef34e3bd5 100755 (executable)
@@ -84,10 +84,6 @@ foreach my $recipient (keys %dests) {
                $im->add($mime);
        }
        $im->done;
-       eval {
-               require PublicInbox::SearchIdx;
-               PublicInbox::SearchIdx->new($git_dir, 2)->index_sync;
-       };
 }
 
 if ($err) {
index 26b70cfb6cfc8f2fc7d4631b829648e0e34d068f..145aa7106b958a20083eeba9b74678497b06bd71 100755 (executable)
@@ -79,7 +79,6 @@ if (ref($ret) && $ret->isa('Email::MIME')) { # filter altered message
 } # else { accept
 
 PublicInbox::MDA->set_list_headers($mime, $dst);
-END { index_sync($main_repo) if $? == 0 };
 my $git = PublicInbox::Git->new($main_repo);
 my $im = PublicInbox::Import->new($git, $dst->{name}, $recipient);
 if (defined $im->add($mime)) {
@@ -107,11 +106,3 @@ sub do_spamc {
 
        ($? || $$out eq '') ? 0 : 1;
 }
-
-sub index_sync {
-       my ($git_dir) = @_;
-       eval {
-               require PublicInbox::SearchIdx;
-               PublicInbox::SearchIdx->new($git_dir, 2)->index_sync;
-       };
-}