From a4e0d3e9302aa16b966ea5d84926664748ba9ae2 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 4 Sep 2011 11:58:45 -0400 Subject: [PATCH] dload: abstract dload_interrupted reasons This gives us some amount of room to grow in case we ever find another reason that we might return with an error from the progress callback. Signed-off-by: Dave Reisner --- lib/libalpm/dload.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index 83f969c8..ec3f4989 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -66,10 +66,15 @@ static char *get_fullpath(const char *path, const char *filename, return filepath; } +enum { + ABORT_SIGINT = 1, + ABORT_OVER_MAXFILESIZE +}; + static int dload_interrupted; static void inthandler(int UNUSED signum) { - dload_interrupted = 1; + dload_interrupted = ABORT_SIGINT; } static int curl_progress(void *file, double dltotal, double dlnow, @@ -87,6 +92,7 @@ static int curl_progress(void *file, double dltotal, double dlnow, /* is our filesize still under any set limit? */ if(payload->max_size && current_size > payload->max_size) { + dload_interrupted = ABORT_OVER_MAXFILESIZE; return 1; } @@ -359,8 +365,8 @@ static int curl_download_internal(struct dload_payload *payload, } break; case CURLE_ABORTED_BY_CALLBACK: - /* two cases here- interrupted by user, or we exceeded max file size. */ - if(!dload_interrupted) { + /* handle the interrupt accordingly */ + if(dload_interrupted == ABORT_OVER_MAXFILESIZE) { handle->curlerr = CURLE_FILESIZE_EXCEEDED; handle->pm_errno = ALPM_ERR_LIBCURL; /* the hardcoded 'size exceeded' message is same as libcurl's normal */