]> Sergey Matveev's repositories - public-inbox.git/commitdiff
public-inbox-{learn,mda}: automatically sync index
authorEric Wong <e@80x24.org>
Mon, 17 Aug 2015 08:19:44 +0000 (08:19 +0000)
committerEric Wong <e@80x24.org>
Mon, 17 Aug 2015 08:51:35 +0000 (08:51 +0000)
We'll ignore errors, for now, but should eventually warn or
log.  And yes, this is a dirty, dirty hack but we'll fix this
ASAP tomorrow.

public-inbox-learn
public-inbox-mda

index d3a05abe4cfcb1e17d7d37532343dd756d336961..7f525f558f5d17b26b2c21742bab48631b984a08 100755 (executable)
@@ -76,5 +76,15 @@ foreach my $recipient (keys %dests) {
        if (!run([qw(spamc -L), $train], \$in, @output)) {
                $err = 1;
        }
+
+       $err or eval {
+               require PublicInbox::Search;
+               require PublicInbox::GitCatFile;
+               my $git = PublicInbox::GitCatFile->new($git_dir);
+               umask 0022; # XXX FIXME use git config core.sharedRepository
+               my $s = PublicInbox::Search->new($git_dir, 1);
+               $s->index_sync($git);
+       };
 }
+
 exit $err;
index 4348cb244510113a2cb40d0ca8e5eac0e9be13cb..46a24a14b8df80ab9b084e784a78deedc0bda2d9 100755 (executable)
@@ -47,6 +47,11 @@ if (PublicInbox::MDA->precheck($filter, $dst->{address}) &&
 
                        my ($name, $email, $date) =
                                        PublicInbox::MDA->author_info($msg);
+
+                       END {
+                               search_index_sync($main_repo) if ($? == 0);
+                       };
+
                        local $ENV{GIT_AUTHOR_NAME} = $name;
                        local $ENV{GIT_AUTHOR_EMAIL} = $email;
                        local $ENV{GIT_AUTHOR_DATE} = $date;
@@ -79,3 +84,15 @@ sub do_spamc {
 
        return ($@ || $? || !defined($$out) || length($$out) == 0) ? 0 : 1;
 }
+
+sub search_index_sync {
+       my ($git_dir) = @_;
+       eval {
+               require PublicInbox::Search;
+               require PublicInbox::GitCatFile;
+               my $git = PublicInbox::GitCatFile->new($git_dir);
+               umask 0022; # XXX FIXME use git config core.sharedRepository
+               my $s = PublicInbox::Search->new($git_dir, 1);
+               $s->index_sync($git);
+       };
+}