diff options
author | Dave Reisner <dreisner@archlinux.org> | 2011-09-04 11:58:45 -0400 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-09-06 08:44:14 -0500 |
commit | a4e0d3e9302aa16b966ea5d84926664748ba9ae2 (patch) | |
tree | 5d0a0865f4e9680d91fec2a441078a483fcc1d6c | |
parent | 6c236277a3d5b444a30790702b8114b6658696a2 (diff) | |
download | pacman-a4e0d3e9302aa16b966ea5d84926664748ba9ae2.tar.xz |
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 <dreisner@archlinux.org>
-rw-r--r-- | lib/libalpm/dload.c | 12 |
1 files 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 */ |