X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FFetch.pm;h=0539fe505e42750de4c6fb483ef936041b6b1fbf;hb=6393ec8118e7f5481ab476c2d73614c89c64866f;hp=9ea55e9dcf9272d2ddd6e2715433babccc1a80f4;hpb=ae6cd61cf7cb9988d6e9178dbdeebfb6109e74da;p=public-inbox.git diff --git a/lib/PublicInbox/Fetch.pm b/lib/PublicInbox/Fetch.pm index 9ea55e9d..0539fe50 100644 --- a/lib/PublicInbox/Fetch.pm +++ b/lib/PublicInbox/Fetch.pm @@ -75,12 +75,22 @@ sub do_manifest ($$$) { my $t1 = $cur->{modified} // next; delete($mdiff->{$k}) if $f0 eq $f1 && $t0 == $t1; } - return unless keys %$mdiff; + unless (keys %$mdiff) { + $lei->child_error(127 << 8) if $lei->{opt}->{'exit-code'}; + return; + } my (undef, $v1_path, @v2_epochs) = PublicInbox::LeiMirror::deduce_epochs($mdiff, $ibx_uri->path); [ 200, $v1_path, \@v2_epochs, $muri, $ft, $mf ]; } +sub get_fingerprint2 { + my ($git_dir) = @_; + require Digest::SHA; + my $rd = popen_rd([qw(git show-ref)], undef, { -C => $git_dir }); + Digest::SHA::sha256(do { local $/; <$rd> }); +} + sub do_fetch { my ($cls, $lei, $cd) = @_; my $ibx_ver; @@ -136,11 +146,14 @@ EOM } # n.b. this expects all epochs are from the same host my $torsocks = $lei->{curl}->torsocks($lei, $muri); + my $fp2 = $lei->{opt}->{'exit-code'} ? [] : undef; + my $xit = 127; for my $d (@git_dir) { my $cmd; my $opt = {}; # for spawn if (-d $d) { $opt->{-C} = $d; + $fp2->[0] = get_fingerprint2($d) if $fp2; $cmd = [ @$torsocks, fetch_cmd($lei, $opt) ]; } else { my $e_uri = $ibx_uri->clone; @@ -152,6 +165,7 @@ EOM PublicInbox::LeiMirror::clone_cmd($lei, $opt), $$e_uri, $d]; push @new_epoch, substr($epath, 5, -4) + 0; + $xit = 0; } my $cerr = PublicInbox::LeiMirror::run_reap($lei, $cmd, $opt); # do not bail on clone failure if we didn't have a manifest @@ -159,6 +173,10 @@ EOM $lei->child_error($cerr, "@$cmd failed"); return; } + if ($fp2 && $xit) { + $fp2->[1] = get_fingerprint2($d); + $xit = 0 if $fp2->[0] ne $fp2->[1]; + } } for my $i (@new_epoch) { $mg->epoch_cfg_set($i) } if ($ft) { @@ -166,6 +184,7 @@ EOM rename($fn, $mf) or die "E: rename($fn, $mf): $!\n"; $ft->unlink_on_destroy(0); } + $lei->child_error($xit << 8) if $fp2 && $xit; } 1;