Do not use counter for error tracking
Current code uses an incrementing counter to check whether a function returned error: errors += some_function(); if(errors) { goto finish } Replace with a more standard variable errors = some_function(); if(errors) { goto finish } Rename 'errors' variable to a more typical 'ret'. Avoid reporting both ALPM_EVENT_PKG_RETRIEVE_FAILED and ALPM_EVENT_PKG_RETRIEVE_DONE in the error path. Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
f078c2d3bc
commit
34ba8d984d
1 changed files with 10 additions and 8 deletions
|
@ -730,7 +730,7 @@ static int download_files(alpm_handle_t *handle)
|
||||||
{
|
{
|
||||||
const char *cachedir;
|
const char *cachedir;
|
||||||
alpm_list_t *i, *files = NULL;
|
alpm_list_t *i, *files = NULL;
|
||||||
int errors = 0;
|
int ret = 0;
|
||||||
alpm_event_t event;
|
alpm_event_t event;
|
||||||
alpm_list_t *payloads = NULL;
|
alpm_list_t *payloads = NULL;
|
||||||
|
|
||||||
|
@ -750,14 +750,16 @@ static int download_files(alpm_handle_t *handle)
|
||||||
handle->totaldlcb(total_size);
|
handle->totaldlcb(total_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
errors += find_dl_candidates(handle, &files);
|
ret = find_dl_candidates(handle, &files);
|
||||||
|
if(ret) {
|
||||||
|
goto finish;
|
||||||
|
}
|
||||||
|
|
||||||
if(files && !errors) {
|
if(files) {
|
||||||
/* check for necessary disk space for download */
|
/* check for necessary disk space for download */
|
||||||
if(handle->checkspace) {
|
if(handle->checkspace) {
|
||||||
off_t *file_sizes;
|
off_t *file_sizes;
|
||||||
size_t idx, num_files;
|
size_t idx, num_files;
|
||||||
int ret;
|
|
||||||
|
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG, "checking available disk space for download\n");
|
_alpm_log(handle, ALPM_LOG_DEBUG, "checking available disk space for download\n");
|
||||||
|
|
||||||
|
@ -773,7 +775,6 @@ static int download_files(alpm_handle_t *handle)
|
||||||
free(file_sizes);
|
free(file_sizes);
|
||||||
|
|
||||||
if(ret != 0) {
|
if(ret != 0) {
|
||||||
errors++;
|
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -796,12 +797,13 @@ static int download_files(alpm_handle_t *handle)
|
||||||
|
|
||||||
payloads = alpm_list_add(payloads, payload);
|
payloads = alpm_list_add(payloads, payload);
|
||||||
}
|
}
|
||||||
event.type = ALPM_EVENT_PKG_RETRIEVE_DONE;
|
|
||||||
if(_alpm_download(handle, payloads, cachedir) == -1) {
|
if(_alpm_download(handle, payloads, cachedir) == -1) {
|
||||||
errors++;
|
|
||||||
event.type = ALPM_EVENT_PKG_RETRIEVE_FAILED;
|
event.type = ALPM_EVENT_PKG_RETRIEVE_FAILED;
|
||||||
|
EVENT(handle, &event);
|
||||||
_alpm_log(handle, ALPM_LOG_WARNING, _("failed to retrieve some files\n"));
|
_alpm_log(handle, ALPM_LOG_WARNING, _("failed to retrieve some files\n"));
|
||||||
|
goto finish;
|
||||||
}
|
}
|
||||||
|
event.type = ALPM_EVENT_PKG_RETRIEVE_DONE;
|
||||||
EVENT(handle, &event);
|
EVENT(handle, &event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -826,7 +828,7 @@ finish:
|
||||||
handle->totaldlcb(0);
|
handle->totaldlcb(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBGPGME
|
#ifdef HAVE_LIBGPGME
|
||||||
|
|
Loading…
Add table
Reference in a new issue