From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 70B431F8C6 for ; Fri, 10 Sep 2021 09:15:36 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] lei add-external --mirror: quiet unlink error on ENOENT Date: Fri, 10 Sep 2021 09:15:36 +0000 Message-Id: <20210910091536.17210-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 =>