]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei add-external --mirror: quiet unlink error on ENOENT
authorEric Wong <e@80x24.org>
Fri, 10 Sep 2021 09:15:36 +0000 (09:15 +0000)
committerEric Wong <e@80x24.org>
Fri, 10 Sep 2021 09:18:32 +0000 (09:18 +0000)
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
t/lei-mirror.t

index fca11ccff037cae4d5b1f4b37e609c36733629fa..638add421d61df703001f753b0a9d9e426c609f6 100644 (file)
@@ -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}");
index 65b6068ccb917af1ef7992eed14d6276ecd916af..a61a756596fc5b6c14d4db511c37664108af62eb 100644 (file)
@@ -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 =>