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 = {};
$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;
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 ];
$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
my $opt = { -C => $d, 2 => \(my $err) };
ok(!run_script([qw(-clone -q), "$http/404"], undef, $opt), '404 fails');
ok(!-d "$d/404", 'destination not created');
- delete $opt->{2};
ok(run_script([qw(-clone -q -C), $d, "$http/t2"], undef, $opt),
'-clone succeeds on v2');
ok(-d "$d/t2/git/0.git", 'epoch cloned');
ok(-f "$d/t2/manifest.js.gz", 'manifest saved');
ok(!-e "$d/t2/mirror.done", 'no leftover mirror.done');
- ok(run_script([qw(-fetch -q -C), "$d/t2"], undef, $opt),
+ ok(run_script([qw(-fetch -C), "$d/t2"], undef, $opt),
'-fetch succeeds w/ manifest.js.gz');
+ unlike($err, qr/git fetch/, 'no fetch done w/ manifest');
unlink("$d/t2/manifest.js.gz") or xbail "unlink $!";
- ok(run_script([qw(-fetch -q -C), "$d/t2"], undef, $opt),
+ ok(run_script([qw(-fetch -C), "$d/t2"], undef, $opt),
'-fetch succeeds w/o manifest.js.gz');
+ like($err, qr/git fetch/, 'fetch forced w/o manifest');
ok(run_script([qw(-clone -q -C), $d, "$http/t1"], undef, $opt),
'cloning v1 works');
ok(-d "$d/t1", 'v1 cloned');
ok(!-e "$d/t1/mirror.done", 'no leftover file');
- ok(run_script([qw(-fetch -q -C), "$d/t1"], undef, $opt),
+ ok(-f "$d/t1/manifest.js.gz", 'manifest saved');
+ ok(run_script([qw(-fetch -C), "$d/t1"], undef, $opt),
'fetching v1 works');
+ unlike($err, qr/git fetch/, 'no fetch done w/ manifest');
unlink("$d/t1/manifest.js.gz") or xbail "unlink $!";
my $before = [ glob("$d/t1/*") ];
- ok(run_script([qw(-fetch -q -C), "$d/t1"], undef, $opt),
+ ok(run_script([qw(-fetch -C), "$d/t1"], undef, $opt),
'fetching v1 works w/o manifest.js.gz');
unlink("$d/t1/FETCH_HEAD"); # git internal
+ like($err, qr/git fetch/, 'no fetch done w/ manifest');
ok(unlink("$d/t1/manifest.js.gz"), 'manifest created');
my $after = [ glob("$d/t1/*") ];
is_deeply($before, $after, 'no new files created');