Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/sync.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-08-08 19:42:52 -0500
committerDan McGee <dan@archlinux.org>2011-08-08 19:42:52 -0500
commit9d09c9fdf7f6156e81c28045e36970158f26d2f1 (patch)
tree07ec2f636ed155f020d667db56039df6d263a5ec /lib/libalpm/sync.c
parent1d16875db7461a05eee456b39e815893c7aefd96 (diff)
Attempt to fix up some of the brokenness around failed package loads
This is a bit of a mess, due to the fact that we have a progress meter running. It is also ironic that we are in the midst of a method named "commit" when we haven't done a damn thing yet, and can still fail hard if either a checksum or signature is invalid or unrecognized. Adapt the former test_md5sum method to be invoked for any of the various failure types, which at least gives the user some indication of what packages are failing. A second patch will be needed to actually show worthwhile error codes, but this is going to involve modifying the actual data passed with the callback. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/sync.c')
-rw-r--r--lib/libalpm/sync.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index ca7e6579..663fca6c 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -677,24 +677,18 @@ static int apply_deltas(alpm_handle_t *handle)
*
* @param trans the transaction
* @param filename the absolute path of the file to test
- * @param md5sum the expected md5sum of the file
*
- * @return 0 if the md5sum matched, 1 if not, -1 in case of errors
+ * @return 1 if file was removed, 0 otherwise
*/
-static int test_md5sum(alpm_trans_t *trans, const char *filepath,
- const char *md5sum)
+static int prompt_to_delete(alpm_trans_t *trans, const char *filepath)
{
- int ret = _alpm_test_md5sum(filepath, md5sum);
- if(ret == 1) {
- int doremove = 0;
- QUESTION(trans, ALPM_TRANS_CONV_CORRUPTED_PKG, (char *)filepath,
- NULL, NULL, &doremove);
- if(doremove) {
- unlink(filepath);
- }
+ int doremove = 0;
+ QUESTION(trans, ALPM_TRANS_CONV_CORRUPTED_PKG, (char *)filepath,
+ NULL, NULL, &doremove);
+ if(doremove) {
+ unlink(filepath);
}
-
- return ret;
+ return doremove;
}
static int validate_deltas(alpm_handle_t *handle, alpm_list_t *deltas,
@@ -715,7 +709,9 @@ static int validate_deltas(alpm_handle_t *handle, alpm_list_t *deltas,
alpm_delta_t *d = alpm_list_getdata(i);
char *filepath = _alpm_filecache_find(handle, d->delta);
- if(test_md5sum(trans, filepath, d->delta_md5) != 0) {
+ ret = _alpm_test_md5sum(filepath, d->delta_md5);
+ if(ret != 0) {
+ prompt_to_delete(trans, filepath);
errors++;
*data = alpm_list_add(*data, strdup(d->delta));
}
@@ -903,6 +899,7 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
alpm_pkg_t *pkgfile =_alpm_pkg_load_internal(handle, filepath, 1, spkg->md5sum,
spkg->base64_sig, level);
if(!pkgfile) {
+ prompt_to_delete(trans, filepath);
errors++;
*data = alpm_list_add(*data, strdup(filename));
FREE(filepath);
@@ -920,7 +917,10 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
if(errors) {
- RET_ERR(handle, ALPM_ERR_PKG_INVALID, -1);
+ if(!handle->pm_errno) {
+ RET_ERR(handle, ALPM_ERR_PKG_INVALID, -1);
+ }
+ return -1;
}
if(trans->flags & ALPM_TRANS_FLAG_DOWNLOADONLY) {