mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-23 00:08:50 -05:00
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>
This commit is contained in:
parent
6c236277a3
commit
a4e0d3e930
@ -66,10 +66,15 @@ static char *get_fullpath(const char *path, const char *filename,
|
|||||||
return filepath;
|
return filepath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum {
|
||||||
|
ABORT_SIGINT = 1,
|
||||||
|
ABORT_OVER_MAXFILESIZE
|
||||||
|
};
|
||||||
|
|
||||||
static int dload_interrupted;
|
static int dload_interrupted;
|
||||||
static void inthandler(int UNUSED signum)
|
static void inthandler(int UNUSED signum)
|
||||||
{
|
{
|
||||||
dload_interrupted = 1;
|
dload_interrupted = ABORT_SIGINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int curl_progress(void *file, double dltotal, double dlnow,
|
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? */
|
/* is our filesize still under any set limit? */
|
||||||
if(payload->max_size && current_size > payload->max_size) {
|
if(payload->max_size && current_size > payload->max_size) {
|
||||||
|
dload_interrupted = ABORT_OVER_MAXFILESIZE;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,8 +365,8 @@ static int curl_download_internal(struct dload_payload *payload,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CURLE_ABORTED_BY_CALLBACK:
|
case CURLE_ABORTED_BY_CALLBACK:
|
||||||
/* two cases here- interrupted by user, or we exceeded max file size. */
|
/* handle the interrupt accordingly */
|
||||||
if(!dload_interrupted) {
|
if(dload_interrupted == ABORT_OVER_MAXFILESIZE) {
|
||||||
handle->curlerr = CURLE_FILESIZE_EXCEEDED;
|
handle->curlerr = CURLE_FILESIZE_EXCEEDED;
|
||||||
handle->pm_errno = ALPM_ERR_LIBCURL;
|
handle->pm_errno = ALPM_ERR_LIBCURL;
|
||||||
/* the hardcoded 'size exceeded' message is same as libcurl's normal */
|
/* the hardcoded 'size exceeded' message is same as libcurl's normal */
|
||||||
|
Loading…
Reference in New Issue
Block a user