Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-09-20 15:23:21 -0500
committerDan McGee <dan@archlinux.org>2011-09-22 10:32:24 -0500
commit01f5c9e79ab2e051349f941b7ecce80d9a251603 (patch)
treefbdbf84a8c05f8193ad9e98318d5d337c3b5d9bd
parent5e7875ae6a42de40e3a7432ea758b27397a11aa7 (diff)
validate_deltas: split verify/check errors loops
This allows us to do all delta verification up front, followed by whatever needs to be done with any found errors. In this case, we call prompt_to_delete() for each error. Add back the missing EVENT(ALPM_EVENT_DELTA_INTEGRITY_DONE) that accidentally got removed in commit 062c391919e93f1d6. Remove use of *data; we never even look at the stuff in this array for the error code we were returning and this would be much better handled by one callback per error anyway, or at least some strongly typed return values. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--lib/libalpm/sync.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 2092912e..dda4b241 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -753,11 +753,9 @@ static int prompt_to_delete(alpm_handle_t *handle, const char *filepath,
return doremove;
}
-static int validate_deltas(alpm_handle_t *handle, alpm_list_t *deltas,
- alpm_list_t **data)
+static int validate_deltas(alpm_handle_t *handle, alpm_list_t *deltas)
{
- int errors = 0;
- alpm_list_t *i;
+ alpm_list_t *i, *errors = NULL;
if(!deltas) {
return 0;
@@ -765,19 +763,25 @@ static int validate_deltas(alpm_handle_t *handle, alpm_list_t *deltas,
/* Check integrity of deltas */
EVENT(handle, ALPM_EVENT_DELTA_INTEGRITY_START, NULL, NULL);
-
for(i = deltas; i; i = i->next) {
alpm_delta_t *d = i->data;
char *filepath = _alpm_filecache_find(handle, d->delta);
if(_alpm_test_checksum(filepath, d->delta_md5, ALPM_CSUM_MD5)) {
- prompt_to_delete(handle, filepath, ALPM_ERR_DLT_INVALID);
- errors++;
- *data = alpm_list_add(*data, strdup(d->delta));
+ errors = alpm_list_add(errors, filepath);
+ } else {
+ FREE(filepath);
}
- FREE(filepath);
}
+ EVENT(handle, ALPM_EVENT_DELTA_INTEGRITY_DONE, NULL, NULL);
+
if(errors) {
+ for(i = errors; i; i = i->next) {
+ char *filepath = i->data;
+ prompt_to_delete(handle, filepath, ALPM_ERR_DLT_INVALID);
+ FREE(filepath);
+ }
+ alpm_list_free(errors);
handle->pm_errno = ALPM_ERR_DLT_INVALID;
return -1;
}
@@ -1024,7 +1028,7 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
return -1;
}
- if(validate_deltas(handle, deltas, data)) {
+ if(validate_deltas(handle, deltas)) {
alpm_list_free(deltas);
return -1;
}