[pacman-dev] [PATCH 4/6] lib/dload: unlink on response code >=400
Dave Reisner
d at falconindy.com
Thu Aug 18 21:09:34 EDT 2011
ftp and http both define >=400 as being "something bad happened"
Signed-off-by: Dave Reisner <dreisner at archlinux.org>
---
Fewer .part files left behind...
lib/libalpm/dload.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index a7a13b6..f03fabd 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -263,7 +263,7 @@ static int curl_download_internal(struct dload_payload *payload,
/* RFC1123 states applications should support this length */
char hostname[256];
char error_buffer[CURL_ERROR_SIZE] = { 0 };
- long timecond, remote_time = -1;
+ long timecond, respcode = 0, remote_time = -1;
double remote_size, bytes_dl;
struct sigaction sig_pipe, sig_int;
/* shortcut to our handle within the payload */
@@ -328,6 +328,12 @@ static int curl_download_internal(struct dload_payload *payload,
/* was it a success? */
switch(handle->curlerr) {
case CURLE_OK:
+ /* get http/ftp response code */
+ curl_easy_getinfo(handle->curl, CURLINFO_RESPONSE_CODE, &respcode);
+ if(respcode >=400) {
+ payload->unlink_on_fail = 1;
+ goto cleanup;
+ }
break;
case CURLE_ABORTED_BY_CALLBACK:
goto cleanup;
--
1.7.6
More information about the pacman-dev
mailing list