summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Whitaker <mageia@martin-whitaker.me.uk>2022-11-05 13:20:36 +0000
committerMartin Whitaker <mageia@martin-whitaker.me.uk>2022-11-05 14:53:08 +0000
commite1a34a4e643f1907ea43fe5244ed6ebe081f4a93 (patch)
treef0cf057aa379bdd3b66d5db4ac19456ddb1c8b59
parente23128656aaa5e6b505600a0b2c6fef39922c01a (diff)
downloadurpmi-e1a34a4e643f1907ea43fe5244ed6ebe081f4a93.tar
urpmi-e1a34a4e643f1907ea43fe5244ed6ebe081f4a93.tar.gz
urpmi-e1a34a4e643f1907ea43fe5244ed6ebe081f4a93.tar.bz2
urpmi-e1a34a4e643f1907ea43fe5244ed6ebe081f4a93.tar.xz
urpmi-e1a34a4e643f1907ea43fe5244ed6ebe081f4a93.zip
library: fix download with curl 7.86+ when the URL has a query part (mga#31047)
curl 7.86 changed the -O option to remove any trailing query part from the output file name. So if we have a query part, use the -o option instead.
-rw-r--r--Changes2
-rw-r--r--urpm/download.pm13
2 files changed, 13 insertions, 2 deletions
diff --git a/Changes b/Changes
index 7fae79b0..3f148ceb 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,5 @@
+- library:
+ o fix download with curl 7.86+ when the URL has a query part (mga#31047)
- gurpmi2:
o fix Cancel button getting lost after first batch of downloads is done
diff --git a/urpm/download.pm b/urpm/download.pm
index b1ea6454..8ee2ba12 100644
--- a/urpm/download.pm
+++ b/urpm/download.pm
@@ -488,8 +488,8 @@ sub sync_curl {
#- options for http files, -R (-O <file>)*
my $result;
if (my @all_files = (
- (map { ("-O", $_) } @ftp_files),
- (map { m|/| ? ("-O", $_) : @{[]} } @other_files)))
+ (map { (_curl_output_option($_), $_) } @ftp_files),
+ (map { m|/| ? (_curl_output_option($_), $_) : @{[]} } @other_files)))
{
my @l = (@ftp_files, @other_files);
my $cmd = join(" ", map { "'$_'" } "/usr/bin/curl",
@@ -516,6 +516,15 @@ sub sync_curl {
$result;
}
+sub _curl_output_option {
+ my ($remote_file) = @_;
+ #- curl 7.86 changed the -O option to remove any trailing query part from the output
+ #- file name. So if we have a query part, use the -o option instead. If not, use the
+ #- -O option to avoid bloating the command line.
+ my $local_file = basename($remote_file);
+ $local_file =~ /\?/ ? ('-o', $local_file) : '-O';
+}
+
sub _curl_action {
my ($cmd, $options, @l) = @_;