unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] lei add-external --mirror: quiet unlink error on ENOENT
@ 2021-09-10  9:15 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2021-09-10  9:15 UTC (permalink / raw)
  To: meta

If the mirror.done file doesn't exist for unlink, it's because
we already got another error, so don't confuse users by noting
an unlink error since the ENOENT is expected in the face of
other errors.
---
 lib/PublicInbox/LeiMirror.pm | 2 +-
 t/lei-mirror.t               | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm
index fca11ccf..638add42 100644
--- a/lib/PublicInbox/LeiMirror.pm
+++ b/lib/PublicInbox/LeiMirror.pm
@@ -16,7 +16,7 @@ sub do_finish_mirror { # dwaitpid callback
 	if ($?) {
 		$lei->child_error($?);
 	} elsif (!unlink($f)) {
-		$lei->err("unlink($f): $!");
+		$lei->err("unlink($f): $!") unless $!{ENOENT};
 	} else {
 		$lei->add_external_finish($mrr->{dst});
 		$lei->qerr("# mirrored $mrr->{src} => $mrr->{dst}");
diff --git a/t/lei-mirror.t b/t/lei-mirror.t
index 65b6068c..a61a7565 100644
--- a/t/lei-mirror.t
+++ b/t/lei-mirror.t
@@ -47,6 +47,14 @@ test_lei({ tmpdir => $tmpdir }, sub {
 	lei_ok('add-external', "$t1-pfx", '--mirror', "$http/pfx/t1/",
 			\'--mirror v1 w/ PSGI prefix');
 
+	my $d = "$home/404";
+	ok(!lei(qw(add-external --mirror), "$http/404", $d), 'mirror 404');
+	unlike($lei_err, qr!unlink.*?404/mirror\.done!,
+		'no unlink failure message');
+	ok(!-d $d, "`404' dir not created");
+	lei_ok('ls-external');
+	unlike($lei_out, qr!\Q$d\E!s, 'not added to ls-external');
+
 	my %phail = (
 		HTTPS => 'https://public-inbox.org/' . 'phail',
 		ONION =>

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-10  9:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-10  9:15 [PATCH] lei add-external --mirror: quiet unlink error on ENOENT 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).