From 9f139550f815e2970b8929094e50acfd8b4cc2b7 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Wed, 17 Aug 2011 19:45:57 -0400 Subject: lib/dload: refactor deletion on failure This moves all the delete-on-fail logic to under cleanup label. This also implies should_unlink when a payload is received that doesn't allow resuming. Fixes .db.sig.part files leftover in the sync dir. Signed-off-by: Dave Reisner Signed-off-by: Dan McGee --- lib/libalpm/dload.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'lib/libalpm') diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index 0cd0bf7b..68a68e9c 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -180,7 +180,7 @@ static size_t parse_headers(void *ptr, size_t size, size_t nmemb, void *user) static int curl_download_internal(struct dload_payload *payload, const char *localpath, char **final_file) { - int ret = -1, should_unlink = 0; + int ret = -1, should_unlink = !payload->allow_resume; FILE *localf = NULL; const char *useragent; const char *open_mode = "wb"; @@ -313,16 +313,12 @@ static int curl_download_internal(struct dload_payload *payload, case CURLE_ABORTED_BY_CALLBACK: goto cleanup; case CURLE_OPERATION_TIMEDOUT: - dload_interrupted = 1; /* fallthrough */ default: if(!payload->errors_ok) { handle->pm_errno = ALPM_ERR_LIBCURL; _alpm_log(handle, ALPM_LOG_ERROR, _("failed retrieving file '%s' from %s : %s\n"), payload->filename, hostname, error_buffer); - if(!dload_interrupted) { - unlink(tempfile); - } } else { _alpm_log(handle, ALPM_LOG_DEBUG, "failed retrieving file '%s' from %s : %s\n", payload->filename, hostname, error_buffer); @@ -398,7 +394,7 @@ cleanup: } } - if(dload_interrupted && should_unlink) { + if((ret == -1 || dload_interrupted) && should_unlink) { unlink(tempfile); } -- cgit v1.2.3-70-g09d2