lib/dload: avoid deleting .part file on too-slow xfer
Take this opportunity to refactor the if/then/else logic into a switch/case which is likely going to be needed to fine tune more exceptions in the future. Fixes FS#25531 Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
83f076d3a8
commit
6bf60568f8
1 changed files with 21 additions and 13 deletions
|
@ -306,19 +306,27 @@ static int curl_download_internal(struct dload_payload *payload,
|
||||||
curl_easy_setopt(handle->curl, CURLOPT_NOPROGRESS, 1L);
|
curl_easy_setopt(handle->curl, CURLOPT_NOPROGRESS, 1L);
|
||||||
|
|
||||||
/* was it a success? */
|
/* was it a success? */
|
||||||
if(handle->curlerr == CURLE_ABORTED_BY_CALLBACK) {
|
switch(handle->curlerr) {
|
||||||
goto cleanup;
|
case CURLE_OK:
|
||||||
} else if(handle->curlerr != CURLE_OK) {
|
break;
|
||||||
if(!payload->errors_ok) {
|
case CURLE_ABORTED_BY_CALLBACK:
|
||||||
handle->pm_errno = ALPM_ERR_LIBCURL;
|
goto cleanup;
|
||||||
_alpm_log(handle, ALPM_LOG_ERROR, _("failed retrieving file '%s' from %s : %s\n"),
|
case CURLE_OPERATION_TIMEDOUT:
|
||||||
payload->filename, hostname, error_buffer);
|
dload_interrupted = 1;
|
||||||
} else {
|
/* fallthrough */
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG, "failed retrieving file '%s' from %s : %s\n",
|
default:
|
||||||
payload->filename, hostname, error_buffer);
|
if(!payload->errors_ok) {
|
||||||
}
|
handle->pm_errno = ALPM_ERR_LIBCURL;
|
||||||
unlink(tempfile);
|
_alpm_log(handle, ALPM_LOG_ERROR, _("failed retrieving file '%s' from %s : %s\n"),
|
||||||
goto cleanup;
|
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);
|
||||||
|
}
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* retrieve info about the state of the transfer */
|
/* retrieve info about the state of the transfer */
|
||||||
|
|
Loading…
Add table
Reference in a new issue