Skip to content

Commit 34b6b27

Browse files
committed
Add gzip retry for the sidestore downloads
This is a workaround for the sidestore sometimes returning the content uncompressed.
1 parent 025f92a commit 34b6b27

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Build/Download.pm

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,15 @@ sub download {
197197
die("download of $url failed: $status\n") unless $retry-- > 0 && $res->previous;
198198
warn("retrying $url\n");
199199
}
200-
checkfiledigest($dest, $opt{'digest'}) if $opt{'digest'};
200+
if ($opt{'digest'}) {
201+
eval { checkfiledigest($dest, $opt{'digest'}) };
202+
if ($@ && $opt{'gzip_retry'}) {
203+
unlink($dest);
204+
my @newheaders = (@{$opt{'headers'} || []}, 'Accept-Encoding' => 'gzip');
205+
return download($url, $dest, $destfinal, %opt, 'headers' => \@newheaders, 'gzip_retry' => 0);
206+
}
207+
die($@) if $@;
208+
}
201209
if ($destfinal) {
202210
rename($dest, $destfinal) || die("rename $dest $destfinal: $!\n");
203211
}

PBuild/RemoteAssets.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ sub fedpkg_fetch {
261261
$path = PBuild::Util::urlencode($path);
262262
my $fedpkg_url = $url;
263263
$fedpkg_url =~ s/\/?$/\/$path/;
264-
if (Build::Download::download($fedpkg_url, "$adir/.$assetid.$$", undef, 'retry' => 3, 'digest' => $asset->{'digest'}, 'missingok' => 1, 'headers' => [ 'Accept' => '*/*', 'Accept-Encoding' => 'identity' ])) {
264+
if (Build::Download::download($fedpkg_url, "$adir/.$assetid.$$", undef, 'retry' => 3, 'digest' => $asset->{'digest'}, 'missingok' => 1, 'headers' => [ 'Accept' => '*/*', 'Accept-Encoding' => 'identity' ], 'gzip_retry' => 1)) {
265265
rename_unless_present("$adir/.$assetid.$$", "$adir/$assetid");
266266
}
267267
}

0 commit comments

Comments
 (0)