unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] public-inbox-{learn,mda}: automatically sync index
Date: Mon, 17 Aug 2015 08:20:39 +0000	[thread overview]
Message-ID: <1439799639-7826-1-git-send-email-e@80x24.org> (raw)

We'll ignore errors, for now, but should eventually warn or
log.
---
 public-inbox-learn |  9 +++++++++
 public-inbox-mda   | 12 ++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/public-inbox-learn b/public-inbox-learn
index d3a05ab..9576a55 100755
--- a/public-inbox-learn
+++ b/public-inbox-learn
@@ -76,5 +76,14 @@ 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);
+		my $s = PublicInbox::Search->new($git_dir, 1);
+		$s->index_sync($git);
+	};
 }
+
 exit $err;
diff --git a/public-inbox-mda b/public-inbox-mda
index 4348cb2..a5b9cf8 100755
--- a/public-inbox-mda
+++ b/public-inbox-mda
@@ -54,6 +54,7 @@ if (PublicInbox::MDA->precheck($filter, $dst->{address}) &&
 			local $ENV{GIT_COMMITTER_NAME} = $dst->{listname};
 
 			$filter->pipe(PublicInbox::MDA->cmd, $main_repo);
+			search_index_sync($main_repo);
 		}
 	}
 } else {
@@ -79,3 +80,14 @@ 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);
+		my $s = PublicInbox::Search->new($git_dir, 1);
+		$s->index_sync($git);
+	};
+}
-- 
EW


             reply	other threads:[~2015-08-17  8:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-17  8:20 Eric Wong [this message]
2015-08-17  8:52 ` [PATCH v2] public-inbox-{learn,mda}: automatically sync index Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1439799639-7826-1-git-send-email-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).