diff options
author | Dave Reisner <dreisner@archlinux.org> | 2011-08-18 20:17:30 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-08-19 16:43:19 +0200 |
commit | 24824b54ce6ce3f62417be493d1e29eeb2cc8f53 (patch) | |
tree | 78741e41a4a54a786b4d4e9769160647613f6e9d /lib/libalpm/dload.c | |
parent | 2ca27ab3a14c106a7153dda337a61c79db7a6de0 (diff) | |
download | pacman-24824b54ce6ce3f62417be493d1e29eeb2cc8f53.tar.gz pacman-24824b54ce6ce3f62417be493d1e29eeb2cc8f53.tar.xz |
dload: add 'unlink_on_fail' to payload struct
Let callers of _alpm_download state whether we should delete on fail,
rather than inferring it from context. We still override this decision
and always unlink when a temp file is used.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/dload.c')
-rw-r--r-- | lib/libalpm/dload.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index 37989370..2a1fb41c 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 = !payload->allow_resume; + int ret = -1; FILE *localf = NULL; const char *useragent; const char *open_mode = "wb"; @@ -217,7 +217,7 @@ static int curl_download_internal(struct dload_payload *payload, /* we can't support resuming this kind of download, so a partial transfer * will be destroyed */ - should_unlink = 1; + payload->unlink_on_fail = 1; /* create a random filename, which is opened with O_EXCL */ snprintf(randpath, PATH_MAX, "%salpmtmp.XXXXXX", localpath); @@ -312,8 +312,6 @@ static int curl_download_internal(struct dload_payload *payload, break; case CURLE_ABORTED_BY_CALLBACK: goto cleanup; - case CURLE_OPERATION_TIMEDOUT: - /* fallthrough */ default: if(!payload->errors_ok) { handle->pm_errno = ALPM_ERR_LIBCURL; @@ -396,7 +394,7 @@ cleanup: } } - if((ret == -1 || dload_interrupted) && should_unlink && tempfile) { + if((ret == -1 || dload_interrupted) && payload->unlink_on_fail && tempfile) { unlink(tempfile); } |