From 322a79a6421b5993775f63ea25294a97c5203ac0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 14 Jul 2020 02:14:31 +0000 Subject: nntpd+imapd: detect unlinked msgmap While it's even less common to experience a replaced msgmap.sqlite3 file, BOFHs may do the darndest things. This is another step towards reducing the number of needless wakeups we need to do in long-lived read-only daemons. --- t/nntpd.t | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 't/nntpd.t') diff --git a/t/nntpd.t b/t/nntpd.t index 28008ec1..954e6e75 100644 --- a/t/nntpd.t +++ b/t/nntpd.t @@ -14,6 +14,7 @@ use Net::NNTP; use Sys::Hostname; use POSIX qw(_exit); use Digest::SHA; +use_ok 'PublicInbox::Msgmap'; # FIXME: make easier to test both versions my $version = $ENV{PI_TEST_VERSION} || 1; @@ -341,6 +342,13 @@ Date: Fri, 02 Oct 1993 00:00:00 +0000 'article did not exist'); $im->add($ex); $im->done; + { + my $f = $ibx->mm->{filename}; + my $tmp = "$tmpdir/tmp.sqlite3"; + $ibx->mm->{dbh}->sqlite_backup_to_file($tmp); + delete $ibx->{mm}; + rename($tmp, $f) or BAIL_OUT "rename($tmp, $f): $!"; + } ok(run_script([qw(-index --reindex -c), $ibx->{inboxdir}], undef, $noerr), '-compacted'); select(undef, undef, undef, $fast_idle ? 0.1 : 2.1); -- cgit v1.2.3-24-ge0c7