diff options
author | Dave Reisner <dreisner@archlinux.org> | 2011-08-17 19:45:57 -0400 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-08-17 21:03:43 -0500 |
commit | 9f139550f815e2970b8929094e50acfd8b4cc2b7 (patch) | |
tree | 8d7225c6dc4c74d1d4bcc9824014f56eae2af909 /lib | |
parent | 2dbdfe078847dc1247db77580655b387f746ba28 (diff) | |
download | pacman-9f139550f815e2970b8929094e50acfd8b4cc2b7.tar.xz |
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 <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libalpm/dload.c | 8 |
1 files changed, 2 insertions, 6 deletions
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); } |