Skip to content

Commit

Permalink
fix redirect for mirrorlist parameter for zsync files
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-suse committed Apr 8, 2024
1 parent cc30136 commit a0d4e52
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 44 deletions.
51 changes: 11 additions & 40 deletions lib/MirrorCache/Datamodule.pm
Original file line number Diff line number Diff line change
Expand Up @@ -557,48 +557,19 @@ sub _init_path($self) {
push @c_new, $component;
}
$path = '/'.join('/', reverse @c_new);
if(!$trailing_slash && ((my $pos = length($path)-length('.metalink')) > 1)) {
if ('.metalink' eq substr($path,$pos)) {
$self->metalink(1);
$path = substr($path,0,$pos);
}
}
if(!$trailing_slash && ((my $pos = length($path)-length('.meta4')) > 1)) {
if ('.meta4' eq substr($path,$pos)) {
$self->meta4(1);
$path = substr($path,0,$pos);
}
}
if (!$trailing_slash && ((my $pos = length($path) - length('.mirrorlist')) > 1)) {
if ('.mirrorlist' eq substr($path, $pos)) {
$self->mirrorlist(1);
$path = substr($path, 0, $pos);
}
}
if (!$trailing_slash && ((my $pos = length($path) - length('.zsync')) > 1)) {
if ('.zsync' eq substr($path, $pos)) {
$self->zsync(1);
$path = substr($path, 0, $pos);
}
}
if (!$trailing_slash && ((my $pos = length($path) - length('.torrent')) > 1)) {
if ('.torrent' eq substr($path, $pos)) {
$self->torrent(1);
$path = substr($path, 0, $pos);
}
}
if (!$trailing_slash && ((my $pos = length($path) - length('.magnet')) > 1)) {
if ('.magnet' eq substr($path, $pos)) {
$self->magnet(1);
$path = substr($path, 0, $pos);
}
}
if (!$trailing_slash && ((my $pos = length($path) - length('.btih')) > 1)) {
if ('.btih' eq substr($path, $pos)) {
$self->btih(1);
$path = substr($path, 0, $pos);
unless ($trailing_slash || $self->extra) {
my @ext = qw(metalink meta4 mirrorlist zsync torrent magnet btih);
for my $ext (@ext) {
if((my $pos = length($path)-length(".$ext")) > 1) {
if (".$ext" eq substr($path,$pos)) {
$self->$ext(1);
$path = substr($path,0,$pos);
last;
}
}
}
}

$pedantic = $ENV{'MIRRORCACHE_PEDANTIC'} unless defined $pedantic;
if (!defined $pedantic) {
if ( $path =~ m/.*\/([^\/]*-Current[^\/]*)$/ ) {
Expand Down
9 changes: 5 additions & 4 deletions t/environ/03-headquarter-subsidiaries-hashes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,18 @@ mc9/curl -I /download/folder1/file-Media.iso.mirrorlist | grep 'Location: /downl
mc9/curl -I /download/folder1/xcurr.dat | grep "Location: http://$na_address/download/folder1/xcurr.dat"
mc9/curl -I /download/folder1/xcurr.dat.metalink | grep "Location: http://$na_address/download/folder1/xcurr.dat.metalink"
mc9/curl -I /download/folder1/xcurr.dat?meta4 | grep "Location: http://$na_address/download/folder1/xcurr.dat.meta4"
mc9/curl -I /download/folder1/xcurr.dat.mirrorlist | grep '/folder1/file4.1.dat?mirrorlist=1'
mc9/curl -I /download/folder1/xcurr.dat.mirrorlist | grep '/folder1/file4.1.dat?mirrorlist='


mc9/curl -I /download/folder1/xcurr.dat.zsync.mirrorlist | grep 'Location: /download/folder1/file4.1.dat.zsync?mirrorlist=1'
mc9/curl -I /download/folder1/xcurr.dat.zsync.mirrorlist | grep 'Location: /download/folder1/file4.1.dat.zsync?mirrorlist='
mc9/curl -I /download/folder1/xcurr.dat.zsync?mirrorlist | grep 'Location: /download/folder1/file4.1.dat.zsync?mirrorlist='

mc6/sql_test file4.1.dat == "select target from file where name = 'xcurr.dat'"

mc6/curl -IL /download/folder1/xcurr.dat | grep '200 OK'
mc6/curl -I /download/folder1/xcurr.dat.metalink | grep '/folder1/file4.1.dat?metalink=1'
mc6/curl -I /download/folder1/xcurr.dat.metalink | grep '/folder1/file4.1.dat?metalink='
mc6/curl -I /download/folder1/xcurr.dat?meta4 | grep '/folder1/file4.1.dat?meta4='
mc6/curl -I /download/folder1/xcurr.dat.mirrorlist | grep '/folder1/file4.1.dat?mirrorlist=1'
mc6/curl -I /download/folder1/xcurr.dat.mirrorlist | grep '/folder1/file4.1.dat?mirrorlist='

# now the hashes on subsidiaries should be retried and match the headquarter
for i in 6 7 8; do
Expand Down

0 comments on commit a0d4e52

Please sign in to comment.