* [PATCH] public-inbox-{learn,mda}: automatically sync index
@ 2015-08-17 8:20 Eric Wong
2015-08-17 8:52 ` [PATCH v2] " Eric Wong
0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2015-08-17 8:20 UTC (permalink / raw)
To: meta
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH v2] public-inbox-{learn,mda}: automatically sync index
2015-08-17 8:20 [PATCH] public-inbox-{learn,mda}: automatically sync index Eric Wong
@ 2015-08-17 8:52 ` Eric Wong
0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2015-08-17 8:52 UTC (permalink / raw)
To: meta
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 | 10 ++++++++++
public-inbox-mda | 17 +++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/public-inbox-learn b/public-inbox-learn
index d3a05ab..7f525f5 100755
--- a/public-inbox-learn
+++ b/public-inbox-learn
@@ -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;
diff --git a/public-inbox-mda b/public-inbox-mda
index 4348cb2..46a24a1 100755
--- a/public-inbox-mda
+++ b/public-inbox-mda
@@ -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);
+ };
+}
--
EW
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-08-17 8:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-17 8:20 [PATCH] public-inbox-{learn,mda}: automatically sync index Eric Wong
2015-08-17 8:52 ` [PATCH v2] " Eric Wong
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).