From dc489bfd4b4c659b7ebb166ab540b4e767e51aaa Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 12 Sep 2021 11:58:15 +0000 Subject: fetch: drop 304 Not Modified support, simplify comparisons Timestamp comparisons only have 1 second granularity, which isn't nearly enough for our test cases, and probably not for real world use for "git send-email" bursts and fast SMTP servers. We'll continue to check modification times inside the manifest, though, in case an extremely rare SHA-1 collision is found... --- lib/PublicInbox/Fetch.pm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/PublicInbox/Fetch.pm') diff --git a/lib/PublicInbox/Fetch.pm b/lib/PublicInbox/Fetch.pm index 4d501108..6a6daee6 100644 --- a/lib/PublicInbox/Fetch.pm +++ b/lib/PublicInbox/Fetch.pm @@ -53,7 +53,6 @@ sub do_manifest ($$$) { PublicInbox::LeiMirror::decode_manifest($fh, $mf, $mf) }; $lei->err($@) if $@; - push @opt, '-z', $mf if defined($m0); } my $curl_cmd = $lei->{curl}->for_uri($lei, $muri, @opt); my $opt = {}; @@ -64,11 +63,11 @@ sub do_manifest ($$$) { $lei->child_error($cerr, "@$curl_cmd failed"); return; } - return [ 304 ] if !-s $ft; # 304 Not Modified via curl -z my $m1 = PublicInbox::LeiMirror::decode_manifest($ft, $fn, $muri); my $mdiff = { %$m1 }; - # filter out unchanged entries + # filter out unchanged entries. We check modified, too, since + # fingerprints are SHA-1, so there's a teeny chance they'll collide while (my ($k, $v0) = each %{$m0 // {}}) { my $cur = $m1->{$k} // next; my $f0 = $v0->{fingerprint} // next; @@ -77,6 +76,7 @@ sub do_manifest ($$$) { my $t1 = $cur->{modified} // next; delete($mdiff->{$k}) if $f0 eq $f1 && $t0 == $t1; } + return unless keys %$mdiff; my (undef, $v1_path, @v2_epochs) = PublicInbox::LeiMirror::deduce_epochs($mdiff, $ibx_uri->path); [ 200, $v1_path, \@v2_epochs, $muri, $ft, $mf ]; @@ -118,7 +118,6 @@ EOM $lei->qerr("# inbox URL: $ibx_uri/"); my $res = do_manifest($lei, $dir, $ibx_uri) or return; my ($code, $v1_path, $v2_epochs, $muri, $ft, $mf) = @$res; - return if $code == 304; if ($code == 404) { # any pre-manifest.js.gz instances running? Just fetch all # existing ones and unconditionally try cloning the next -- cgit v1.2.3-24-ge0c7