]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei_mirror: ensure curl exits 22 on HTTP 404 responses
authorEric Wong <e@80x24.org>
Mon, 28 Nov 2022 05:31:35 +0000 (05:31 +0000)
committerEric Wong <e@80x24.org>
Mon, 28 Nov 2022 23:38:55 +0000 (23:38 +0000)
Oops, this is actually a long-standing bug :x

lib/PublicInbox/LeiMirror.pm

index 279ce30e76d0e7c73ba7217750ad8f5439115d93..acf086654089f4d2cbf8f0d7c25eddd01271086b 100644 (file)
@@ -46,7 +46,7 @@ sub try_scrape {
        my $uri = URI->new($self->{src});
        my $lei = $self->{lei};
        my $curl = $self->{curl} //= PublicInbox::LeiCurl->new($lei) or return;
-       my $cmd = $curl->for_uri($lei, $uri, '--compressed');
+       my $cmd = $curl->for_uri($lei, $uri, qw(-f --compressed));
        my $opt = { 0 => $lei->{0}, 2 => $lei->{2} };
        my $fh = popen_rd($cmd, undef, $opt);
        my $html = do { local $/; <$fh> } // die "read(curl $uri): $!";
@@ -132,7 +132,7 @@ sub _get_txt_start { # non-fatal
        my $f = (split(m!/!, $endpoint))[-1];
        my $ft = File::Temp->new(TEMPLATE => "$f-XXXX", TMPDIR => 1);
        my $opt = { 0 => $lei->{0}, 1 => $lei->{1}, 2 => $lei->{2} };
-       my $cmd = $self->{curl}->for_uri($lei, $uri, qw(--compressed -R -o),
+       my $cmd = $self->{curl}->for_uri($lei, $uri, qw(-f --compressed -R -o),
                                        $ft->filename);
        my $jobs = $lei->{opt}->{jobs} // 1;
        reap_live() while keys(%$LIVE) >= $jobs;
@@ -607,7 +607,7 @@ sub try_manifest {
        my $ft = File::Temp->new(TEMPLATE => '.manifest-XXXX',
                                UNLINK => 1, TMPDIR => 1, SUFFIX => '.tmp');
        my $fn = $ft->filename;
-       my $cmd = $curl->for_uri($lei, $uri, '-R', '-o', $fn);
+       my $cmd = $curl->for_uri($lei, $uri, qw(-f -R -o), $fn);
        my %opt = map { $_ => $lei->{$_} } (0..2);
        my $cerr = run_reap($lei, $cmd, \%opt);
        if ($cerr) {