From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Cc: Eric Wong <e@yhbt.net>
Subject: [PATCH 03/11] rename WatchMaildir => Watch
Date: Mon, 31 Aug 2020 04:41:32 +0000 [thread overview]
Message-ID: <20200831044140.17027-4-e@80x24.org> (raw)
In-Reply-To: <20200831044140.17027-1-e@80x24.org>
From: Eric Wong <e@yhbt.net>
This is no longer limited to Maildirs now that IMAP and NNTP
support exist; so give it a shorter name.
---
MANIFEST | 2 +-
lib/PublicInbox/{WatchMaildir.pm => Watch.pm} | 2 +-
script/public-inbox-watch | 18 +++++++--------
t/imapd.t | 2 +-
t/nntpd.t | 2 +-
t/watch_filter_rubylang.t | 4 ++--
t/watch_imap.t | 4 ++--
t/watch_maildir.t | 18 +++++++--------
t/watch_maildir_v2.t | 22 +++++++++----------
| 4 ++--
t/watch_nntp.t | 4 ++--
11 files changed, 41 insertions(+), 41 deletions(-)
rename lib/PublicInbox/{WatchMaildir.pm => Watch.pm} (99%)
diff --git a/MANIFEST b/MANIFEST
index 35adc8d3..f090175e 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -200,7 +200,7 @@ lib/PublicInbox/ViewDiff.pm
lib/PublicInbox/ViewVCS.pm
lib/PublicInbox/WWW.pm
lib/PublicInbox/WWW.pod
-lib/PublicInbox/WatchMaildir.pm
+lib/PublicInbox/Watch.pm
lib/PublicInbox/WwwAltId.pm
lib/PublicInbox/WwwAtomStream.pm
lib/PublicInbox/WwwAttach.pm
diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/Watch.pm
similarity index 99%
rename from lib/PublicInbox/WatchMaildir.pm
rename to lib/PublicInbox/Watch.pm
index 1c7ac6c0..5f786139 100644
--- a/lib/PublicInbox/WatchMaildir.pm
+++ b/lib/PublicInbox/Watch.pm
@@ -3,7 +3,7 @@
#
# ref: https://cr.yp.to/proto/maildir.html
# http://wiki2.dovecot.org/MailboxFormat/Maildir
-package PublicInbox::WatchMaildir;
+package PublicInbox::Watch;
use strict;
use v5.10.1;
use PublicInbox::Eml;
diff --git a/script/public-inbox-watch b/script/public-inbox-watch
index 20534bf2..02491860 100755
--- a/script/public-inbox-watch
+++ b/script/public-inbox-watch
@@ -3,7 +3,7 @@
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use strict;
use IO::Handle;
-use PublicInbox::WatchMaildir;
+use PublicInbox::Watch;
use PublicInbox::Config;
use PublicInbox::DS;
use PublicInbox::Sigfd;
@@ -11,18 +11,18 @@ use PublicInbox::Syscall qw($SFD_NONBLOCK);
my $oldset = PublicInbox::Sigfd::block_signals();
STDOUT->autoflush(1);
STDERR->autoflush(1);
-my ($config, $watch_md);
+my ($config, $watch);
my $reload = sub {
$config = PublicInbox::Config->new;
- $watch_md->quit if $watch_md;
- $watch_md = PublicInbox::WatchMaildir->new($config);
+ $watch->quit if $watch;
+ $watch = PublicInbox::Watch->new($config);
};
$reload->();
-if ($watch_md) {
- my $scan = sub { $watch_md->trigger_scan('full') if $watch_md };
+if ($watch) {
+ my $scan = sub { $watch->trigger_scan('full') if $watch };
my $quit = sub {
- $watch_md->quit if $watch_md;
- $watch_md = undef;
+ $watch->quit if $watch;
+ $watch = undef;
};
my $sig = {
HUP => $reload,
@@ -41,5 +41,5 @@ if ($watch_md) {
PublicInbox::Sigfd::set_sigmask($oldset);
PublicInbox::DS->SetLoopTimeout(1000);
}
- $watch_md->watch($sig, $oldset) while ($watch_md);
+ $watch->watch($sig, $oldset) while ($watch);
}
diff --git a/t/imapd.t b/t/imapd.t
index 8db72bd7..f743bf06 100644
--- a/t/imapd.t
+++ b/t/imapd.t
@@ -449,7 +449,7 @@ ok($mic->logout, 'logged out');
}
SKIP: {
- use_ok 'PublicInbox::WatchMaildir';
+ use_ok 'PublicInbox::Watch';
use_ok 'PublicInbox::InboxIdle';
require_git('1.8.5', 1) or
skip('git 1.8.5+ needed for --urlmatch', 4);
diff --git a/t/nntpd.t b/t/nntpd.t
index 74e21a41..d8a44334 100644
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -396,7 +396,7 @@ sub read_til_dot {
sub test_watch {
my ($tmpdir, $sock, $group) = @_;
- use_ok 'PublicInbox::WatchMaildir';
+ use_ok 'PublicInbox::Watch';
use_ok 'PublicInbox::InboxIdle';
use_ok 'PublicInbox::Config';
require_git('1.8.5', 1) or skip('git 1.8.5+ needed for --urlmatch', 4);
diff --git a/t/watch_filter_rubylang.t b/t/watch_filter_rubylang.t
index db48cb2f..4b72dbae 100644
--- a/t/watch_filter_rubylang.t
+++ b/t/watch_filter_rubylang.t
@@ -7,7 +7,7 @@ use Test::More;
use PublicInbox::Eml;
use PublicInbox::Config;
require_mods(qw(DBD::SQLite Search::Xapian));
-use_ok 'PublicInbox::WatchMaildir';
+use_ok 'PublicInbox::Watch';
use_ok 'PublicInbox::Emergency';
my ($tmpdir, $for_destroy) = tmpdir();
local $ENV{PI_CONFIG} = "$tmpdir/pi_config";
@@ -76,7 +76,7 @@ EOF
my $ibx = $config->lookup_name($v);
ok($ibx, 'found inbox by name');
- my $w = PublicInbox::WatchMaildir->new($config);
+ my $w = PublicInbox::Watch->new($config);
for my $i (1..2) {
$w->scan('full');
}
diff --git a/t/watch_imap.t b/t/watch_imap.t
index 9433bb6f..fb71d3df 100644
--- a/t/watch_imap.t
+++ b/t/watch_imap.t
@@ -5,14 +5,14 @@ use Test::More;
use PublicInbox::Config;
# see t/imapd*.t for tests against a live IMAP server
-use_ok 'PublicInbox::WatchMaildir';
+use_ok 'PublicInbox::Watch';
my $cfg = PublicInbox::Config->new(\<<EOF);
publicinbox.i.address=i\@example.com
publicinbox.i.inboxdir=/nonexistent
publicinbox.i.watch=imap://example.com/INBOX.a
publicinboxlearn.watchspam=imap://example.com/INBOX.spam
EOF
-my $watch = PublicInbox::WatchMaildir->new($cfg);
+my $watch = PublicInbox::Watch->new($cfg);
is($watch->{imap}->{'imap://example.com/INBOX.a'}->[0]->{name}, 'i',
'watched an inbox');
is($watch->{imap}->{'imap://example.com/INBOX.spam'}, 'watchspam',
diff --git a/t/watch_maildir.t b/t/watch_maildir.t
index c44273f0..ae53caf9 100644
--- a/t/watch_maildir.t
+++ b/t/watch_maildir.t
@@ -11,7 +11,7 @@ my ($tmpdir, $for_destroy) = tmpdir();
my $git_dir = "$tmpdir/test.git";
my $maildir = "$tmpdir/md";
my $spamdir = "$tmpdir/spam";
-use_ok 'PublicInbox::WatchMaildir';
+use_ok 'PublicInbox::Watch';
use_ok 'PublicInbox::Emergency';
my $cfgpfx = "publicinbox.test";
my $addr = 'test-public@example.com';
@@ -40,7 +40,7 @@ $cfgpfx.inboxdir=$git_dir
$cfgpfx.watch=maildir:$spamdir
publicinboxlearn.watchspam=maildir:$spamdir
EOF
- my $wm = PublicInbox::WatchMaildir->new($config);
+ my $wm = PublicInbox::Watch->new($config);
is(scalar grep(/is a spam folder/, @w), 1, 'got warning about spam');
is_deeply($wm->{mdmap}, { "$spamdir/cur" => 'watchspam' },
'only got the spam folder to watch');
@@ -62,7 +62,7 @@ EOF
}
my $config = PublicInbox::Config->new($cfg_path);
-PublicInbox::WatchMaildir->new($config)->scan('full');
+PublicInbox::Watch->new($config)->scan('full');
my $git = PublicInbox::Git->new($git_dir);
my @list = $git->qx(qw(rev-list refs/heads/master));
is(scalar @list, 1, 'one revision in rev-list');
@@ -79,7 +79,7 @@ my $write_spam = sub {
};
$write_spam->();
is(unlink(glob("$maildir/new/*")), 1, 'unlinked old spam');
-PublicInbox::WatchMaildir->new($config)->scan('full');
+PublicInbox::Watch->new($config)->scan('full');
@list = $git->qx(qw(rev-list refs/heads/master));
is(scalar @list, 2, 'two revisions in rev-list');
@list = $git->qx(qw(ls-tree -r --name-only refs/heads/master));
@@ -93,7 +93,7 @@ To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo\@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html\n);
PublicInbox::Emergency->new($maildir)->prepare(\$msg);
- PublicInbox::WatchMaildir->new($config)->scan('full');
+ PublicInbox::Watch->new($config)->scan('full');
@list = $git->qx(qw(ls-tree -r --name-only refs/heads/master));
is(scalar @list, 1, 'tree has one file');
my $mref = $git->cat_file('HEAD:'.$list[0]);
@@ -101,7 +101,7 @@ More majordomo info at http://vger.kernel.org/majordomo-info.html\n);
is(unlink(glob("$maildir/new/*")), 1, 'unlinked spam');
$write_spam->();
- PublicInbox::WatchMaildir->new($config)->scan('full');
+ PublicInbox::Watch->new($config)->scan('full');
@list = $git->qx(qw(ls-tree -r --name-only refs/heads/master));
is(scalar @list, 0, 'tree is empty');
@list = $git->qx(qw(rev-list refs/heads/master));
@@ -118,7 +118,7 @@ More majordomo info at http://vger.kernel.org/majordomo-info.html\n);
$config->{'publicinboxwatch.spamcheck'} = 'spamc';
{
local $SIG{__WARN__} = sub {}; # quiet spam check warning
- PublicInbox::WatchMaildir->new($config)->scan('full');
+ PublicInbox::Watch->new($config)->scan('full');
}
@list = $git->qx(qw(ls-tree -r --name-only refs/heads/master));
is(scalar @list, 0, 'tree has no files spamc checked');
@@ -133,7 +133,7 @@ More majordomo info at http://vger.kernel.org/majordomo-info.html\n);
PublicInbox::Emergency->new($maildir)->prepare(\$msg);
$config->{'publicinboxwatch.spamcheck'} = 'spamc';
@list = $git->qx(qw(ls-tree -r --name-only refs/heads/master));
- PublicInbox::WatchMaildir->new($config)->scan('full');
+ PublicInbox::Watch->new($config)->scan('full');
@list = $git->qx(qw(ls-tree -r --name-only refs/heads/master));
is(scalar @list, 1, 'tree has one file after spamc checked');
@@ -211,7 +211,7 @@ More majordomo info at http://vger.kernel.org/majordomo-info.html\n);
sub is_maildir {
my ($dir) = @_;
- PublicInbox::WatchMaildir::is_maildir($dir);
+ PublicInbox::Watch::is_maildir($dir);
}
is(is_maildir('maildir:/hello//world'), '/hello/world', 'extra slash gone');
diff --git a/t/watch_maildir_v2.t b/t/watch_maildir_v2.t
index 59ec247e..ca1cf965 100644
--- a/t/watch_maildir_v2.t
+++ b/t/watch_maildir_v2.t
@@ -14,7 +14,7 @@ my ($tmpdir, $for_destroy) = tmpdir();
my $inboxdir = "$tmpdir/v2";
my $maildir = "$tmpdir/md";
my $spamdir = "$tmpdir/spam";
-use_ok 'PublicInbox::WatchMaildir';
+use_ok 'PublicInbox::Watch';
use_ok 'PublicInbox::Emergency';
my $cfgpfx = "publicinbox.test";
my $addr = 'test-public@example.com';
@@ -49,7 +49,7 @@ my $ibx = $config->lookup_name('test');
ok($ibx, 'found inbox by name');
my $srch = $ibx->search;
-PublicInbox::WatchMaildir->new($config)->scan('full');
+PublicInbox::Watch->new($config)->scan('full');
my $total = scalar @{$srch->reopen->query('')};
is($total, 1, 'got one revision');
@@ -69,7 +69,7 @@ my $write_spam = sub {
};
$write_spam->();
is(unlink(glob("$maildir/new/*")), 1, 'unlinked old spam');
-PublicInbox::WatchMaildir->new($config)->scan('full');
+PublicInbox::Watch->new($config)->scan('full');
is_deeply($srch->reopen->query(''), [], 'deleted file');
is(unlink(glob("$spamdir/cur/*")), 1, 'unlinked trained spam');
@@ -80,7 +80,7 @@ To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo\@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html\n);
PublicInbox::Emergency->new($maildir)->prepare(\$msg);
- PublicInbox::WatchMaildir->new($config)->scan('full');
+ PublicInbox::Watch->new($config)->scan('full');
my $msgs = $srch->reopen->query('');
is(scalar(@$msgs), 1, 'got one file back');
my $mref = $ibx->msg_by_smsg($msgs->[0]);
@@ -88,7 +88,7 @@ More majordomo info at http://vger.kernel.org/majordomo-info.html\n);
is(unlink(glob("$maildir/new/*")), 1, 'unlinked spam');
$write_spam->();
- PublicInbox::WatchMaildir->new($config)->scan('full');
+ PublicInbox::Watch->new($config)->scan('full');
$msgs = $srch->reopen->query('');
is(scalar(@$msgs), 0, 'inbox is empty again');
is(unlink(glob("$spamdir/cur/*")), 1, 'unlinked trained spam');
@@ -103,7 +103,7 @@ More majordomo info at http://vger.kernel.org/majordomo-info.html\n);
$config->{'publicinboxwatch.spamcheck'} = 'spamc';
{
local $SIG{__WARN__} = sub {}; # quiet spam check warning
- PublicInbox::WatchMaildir->new($config)->scan('full');
+ PublicInbox::Watch->new($config)->scan('full');
}
my $msgs = $srch->reopen->query('');
is(scalar(@$msgs), 0, 'inbox is still empty');
@@ -117,7 +117,7 @@ More majordomo info at http://vger.kernel.org/majordomo-info.html\n);
local $ENV{PATH} = $main_path;
PublicInbox::Emergency->new($maildir)->prepare(\$msg);
$config->{'publicinboxwatch.spamcheck'} = 'spamc';
- PublicInbox::WatchMaildir->new($config)->scan('full');
+ PublicInbox::Watch->new($config)->scan('full');
my $msgs = $srch->reopen->query('');
is(scalar(@$msgs), 1, 'inbox has one mail after spamc OK-ed a message');
my $mref = $ibx->msg_by_smsg($msgs->[0]);
@@ -130,7 +130,7 @@ More majordomo info at http://vger.kernel.org/majordomo-info.html\n);
open my $fh, '<', $patch or die "failed to open $patch: $!\n";
$msg = do { local $/; <$fh> };
PublicInbox::Emergency->new($maildir)->prepare(\$msg);
- PublicInbox::WatchMaildir->new($config)->scan('full');
+ PublicInbox::Watch->new($config)->scan('full');
my $msgs = $srch->reopen->query('dfpost:6e006fd7');
is(scalar(@$msgs), 1, 'diff postimage found');
my $post = $msgs->[0];
@@ -161,7 +161,7 @@ Date: Sat, 18 Jun 2016 00:00:00 +0000
both
EOF
PublicInbox::Emergency->new($maildir)->prepare(\$both);
- PublicInbox::WatchMaildir->new($config)->scan('full');
+ PublicInbox::Watch->new($config)->scan('full');
my $msgs = $srch->reopen->query('m:both@b.com');
my $v1 = $config->lookup_name('v1');
my $msg = $v1->git->cat_file($msgs->[0]->{blob});
@@ -186,7 +186,7 @@ EOF
PublicInbox::Emergency->new($maildir)->prepare(\$want);
PublicInbox::Emergency->new($maildir)->prepare(\$do_not_want);
my $config = PublicInbox::Config->new(\$cfg);
- PublicInbox::WatchMaildir->new($config)->scan('full');
+ PublicInbox::Watch->new($config)->scan('full');
$ibx = $config->lookup_name('test');
my $num = $ibx->mm->num_for('do.want@example.com');
ok(defined $num, 'List-ID matched for watch');
@@ -195,7 +195,7 @@ EOF
$cfg = $orig."$cfgpfx.watchheader=X-Mailing-List:no\@example.com\n";
$config = PublicInbox::Config->new(\$cfg);
- PublicInbox::WatchMaildir->new($config)->scan('full');
+ PublicInbox::Watch->new($config)->scan('full');
$ibx = $config->lookup_name('test');
$num = $ibx->mm->num_for('do.not.want@example.com');
ok(defined $num, 'X-Mailing-List matched');
--git a/t/watch_multiple_headers.t b/t/watch_multiple_headers.t
index 0ee96d5f..a0813532 100644
--- a/t/watch_multiple_headers.t
+++ b/t/watch_multiple_headers.t
@@ -9,7 +9,7 @@ require_mods(qw(Search::Xapian DBD::SQLite));
my ($tmpdir, $for_destroy) = tmpdir();
my $inboxdir = "$tmpdir/v2";
my $maildir = "$tmpdir/md";
-use_ok 'PublicInbox::WatchMaildir';
+use_ok 'PublicInbox::Watch';
use_ok 'PublicInbox::Emergency';
my $cfgpfx = "publicinbox.test";
my $addr = 'test-public@example.com';
@@ -62,7 +62,7 @@ $cfgpfx.watchheader=To:$addr
$cfgpfx.watchheader=Cc:$addr
EOF
my $config = PublicInbox::Config->new(\$cfg);
-PublicInbox::WatchMaildir->new($config)->scan('full');
+PublicInbox::Watch->new($config)->scan('full');
my $ibx = $config->lookup_name('test');
ok($ibx, 'found inbox by name');
diff --git a/t/watch_nntp.t b/t/watch_nntp.t
index 98fb1161..ce1a3153 100644
--- a/t/watch_nntp.t
+++ b/t/watch_nntp.t
@@ -5,8 +5,8 @@ use Test::More;
use PublicInbox::Config;
# see t/nntpd*.t for tests against a live NNTP server
-use_ok 'PublicInbox::WatchMaildir';
-my $nntp_url = \&PublicInbox::WatchMaildir::nntp_url;
+use_ok 'PublicInbox::Watch';
+my $nntp_url = \&PublicInbox::Watch::nntp_url;
is('news://example.com/inbox.foo',
$nntp_url->('NEWS://examplE.com/inbox.foo'), 'lowercased');
is('nntps://example.com/inbox.foo',
next prev parent reply other threads:[~2020-08-31 4:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-31 4:41 [PATCH 00/11] watch: fix contention w/ Maildir & NNTP Eric Wong
2020-08-31 4:41 ` [PATCH 01/11] watch: limit batch size of NNTP and IMAP workers, too Eric Wong
2020-08-31 4:41 ` [PATCH 02/11] watchmaildir: use v5.10.1, drop warnings Eric Wong
2020-08-31 4:41 ` Eric Wong [this message]
2020-08-31 4:41 ` [PATCH 04/11] watch: log signal activities to STDERR Eric Wong
2020-08-31 4:41 ` [PATCH 05/11] watch: avoid unnecessary spawning on spam removals Eric Wong
2020-08-31 4:41 ` [PATCH 06/11] watch: block signals before fork on non-signalfd/kevent systems Eric Wong
2020-08-31 4:41 ` [PATCH 07/11] watch: comments and tiny cleanups Eric Wong
2020-08-31 4:41 ` [PATCH 08/11] ds: avoid excessive queueing when reaping PIDs Eric Wong
2020-08-31 4:41 ` [PATCH 09/11] watch: use EOFpipe to reduce dwaitpid wakeups Eric Wong
2020-08-31 4:41 ` [PATCH 10/11] ds: avoid unnecessary timer for waitpid Eric Wong
2020-08-31 4:41 ` [PATCH 11/11] replace ParentPipe with EOFpipe 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=20200831044140.17027-4-e@80x24.org \
--to=e@80x24.org \
--cc=e@yhbt.net \
--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).