From 82fc816d790ac8b2bfaa81575bf85067769ece10 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Fri, 19 Aug 2011 14:07:29 -0400 Subject: dload: delete zero length downloads on curl error In the case of a non-operation (e.g. DNS resolver error), delete the leftover 0 byte .part file. Signed-off-by: Dave Reisner Signed-off-by: Dan McGee --- lib/libalpm/dload.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index c8f52c48..98a7cf85 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -319,6 +319,10 @@ static int curl_download_internal(struct dload_payload *payload, case CURLE_ABORTED_BY_CALLBACK: goto cleanup; default: + /* delete zero length downloads */ + if(stat(tempfile, &st) == 0 && st.st_size == 0) { + payload->unlink_on_fail = 1; + } if(!payload->errors_ok) { handle->pm_errno = ALPM_ERR_LIBCURL; _alpm_log(handle, ALPM_LOG_ERROR, _("failed retrieving file '%s' from %s : %s\n"), -- cgit v1.2.3-70-g09d2