FS#22630 - Default curl command does not return error code on 404 response

Attached to Project: Pacman
Opened by Xyne (Xyne) - Thursday, 27 January 2011, 16:22 GMT
Last edited by Dan McGee (toofishes) - Friday, 28 January 2011, 18:26 GMT
Task Type Bug Report
Category Backend/Core
Status Closed
Assigned To Dan McGee (toofishes)
Architecture All
Severity Low
Priority Normal
Reported Version 3.4.1
Due in Version 3.5.0
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Summary and Info:
Normally pacman will attempt to download from the next server in the mirrorlist when a download fails, e.g.

:: Synchronizing package databases...
error: failed retrieving file 'core.db.tar.gz' from 127.0.0.1 : Not Found
core 36.6K 230.9K/s 00:00:00 [######################] 100%
error: failed retrieving file 'extra.db.tar.gz' from 127.0.0.1 : Not Found
extra 462.2K 788.1K/s 00:00:01 [######################] 100%
xyne-any 6.7K 35.0K/s 00:00:00 [######################] 100%
error: failed retrieving file 'community.db.tar.gz' from 127.0.0.1 : Not Found
community 419.6K 772.0K/s 00:00:01 [######################] 100%
error: failed retrieving file 'multilib.db.tar.gz' from 127.0.0.1 : Not Found
multilib 22.7K 210.1K/s 00:00:00 [######################] 100%



When using the XferCommand (e.g. "/usr/bin/curl -C - %u > %o"), pacman does not detect that the download has failed and does not continue to the next server, e.g.

:: Synchronizing package databases...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6828 100 6828 0 0 8641 0 --:--:-- --:--:-- --:--:-- 17781
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0


If the exit status cannot be used then perhaps pacman could directly check that the file has been downloaded.
This task depends upon

Closed by  Dan McGee (toofishes)
Friday, 28 January 2011, 18:26 GMT
Reason for closing:  Fixed
Additional comments about closing:  f95080884ca
Comment by Dan McGee (toofishes) - Thursday, 27 January 2011, 23:40 GMT
I'm not sure what you are doing to have it not respect the output code; we definitely check it. When you run with --debug do you see a note about the external downloader returning with a non-zero result?
Comment by Xyne (Xyne) - Friday, 28 January 2011, 17:48 GMT
I posted this in response to the following forum post:
https://bbs.archlinux.org/viewtopic.php?pid=884196#p884196


After further investigation, I found that curl exits with 0 because it does not consider 404 File Not Found to be an error (which it technically isn't, as curl has worked as expected).

To make it exit with an error, you can use the "-f" option. I suggest that you update the default pacman.conf's curl XferCommand to:
#XferCommand = /usr/bin/curl -f -C - %u > %

I've tested it and it works as expected.

Comment by Dan McGee (toofishes) - Friday, 28 January 2011, 17:55 GMT
  • Field changed: Summary ([XferCommand] Pacman should try next server in list when download fails. → Default curl command does not return error code on 404 response)
  • Field changed: Status (Unconfirmed → Assigned)
  • Field changed: Category (General → Backend/Core)
  • Task assigned to Dan McGee (toofishes)
I'll update it on maint, but definitely not worth hurrying the fix. Thanks for tracking down the actual problem.

Loading...