FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 08-13-2011, 08:07 PM
Dave Reisner
 
Default 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>
---
lib/libalpm/dload.c | 34 +++++++++++++++++++++-------------
1 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index 6709084..5a63e48 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -306,19 +306,27 @@ static int curl_download_internal(struct dload_payload *payload,
curl_easy_setopt(handle->curl, CURLOPT_NOPROGRESS, 1L);

/* was it a success? */
- if(handle->curlerr == CURLE_ABORTED_BY_CALLBACK) {
- goto cleanup;
- } else if(handle->curlerr != CURLE_OK) {
- if(!payload->errors_ok) {
- handle->pm_errno = ALPM_ERR_LIBCURL;
- _alpm_log(handle, ALPM_LOG_ERROR, _("failed retrieving file '%s' from %s : %s
"),
- payload->filename, hostname, error_buffer);
- } else {
- _alpm_log(handle, ALPM_LOG_DEBUG, "failed retrieving file '%s' from %s : %s
",
- payload->filename, hostname, error_buffer);
- }
- unlink(tempfile);
- goto cleanup;
+ switch(handle->curlerr) {
+ case CURLE_OK:
+ break;
+ 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
"),
+ payload->filename, hostname, error_buffer);
+ if(!dload_interrupted) {
+ unlink(tempfile);
+ }
+ } else {
+ _alpm_log(handle, ALPM_LOG_DEBUG, "failed retrieving file '%s' from %s : %s
",
+ payload->filename, hostname, error_buffer);
+ }
+ goto cleanup;
}

/* retrieve info about the state of the transfer */
--
1.7.6
 

Thread Tools




All times are GMT. The time now is 04:05 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org