From e1a34a4e643f1907ea43fe5244ed6ebe081f4a93 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sat, 5 Nov 2022 13:20:36 +0000 Subject: 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. --- Changes | 2 ++ urpm/download.pm | 13 +++++++++++-- 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 )* 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) = @_; -- cgit v1.2.1