summaryrefslogtreecommitdiff
path: root/lib/libalpm/sync.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-09-01 16:00:48 -0500
committerDan McGee <dan@archlinux.org>2011-09-02 21:44:39 -0500
commit062c391919e93f1d669deb3ffec60457d57e7d27 (patch)
treee3b634339101e59949683f9c2cff151b585a6f1e /lib/libalpm/sync.c
parent16fd66f879abd52a636ba00cd782b37b1fcf8a65 (diff)
downloadpacman-062c391919e93f1d669deb3ffec60457d57e7d27.tar.xz
Make delta validation/application more logical
The call to apply was tucked inside validate, and the EVENT callbacks were done outside the function rather than inside. Reorganize things a bit to make more sense. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/sync.c')
-rw-r--r--lib/libalpm/sync.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 7106fafe..f125b4a6 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -630,7 +630,7 @@ static int endswith(const char *filename, const char *extension)
static int apply_deltas(alpm_handle_t *handle)
{
alpm_list_t *i;
- int ret = 0;
+ int deltas_found = 0, ret = 0;
const char *cachedir = _alpm_filecache_setup(handle);
alpm_trans_t *trans = handle->trans;
@@ -643,6 +643,13 @@ static int apply_deltas(alpm_handle_t *handle)
continue;
}
+ if(!deltas_found) {
+ /* only show this if we actually have deltas to apply, and it is before
+ * the very first one */
+ EVENT(trans, ALPM_TRANS_EVT_DELTA_PATCHES_START, NULL, NULL);
+ deltas_found = 1;
+ }
+
for(dlts = delta_path; dlts; dlts = dlts->next) {
alpm_delta_t *d = dlts->data;
char *delta, *from, *to;
@@ -702,6 +709,9 @@ static int apply_deltas(alpm_handle_t *handle)
}
}
}
+ if(deltas_found) {
+ EVENT(trans, ALPM_TRANS_EVT_DELTA_PATCHES_DONE, NULL, NULL);
+ }
return ret;
}
@@ -732,7 +742,7 @@ static int prompt_to_delete(alpm_trans_t *trans, const char *filepath,
static int validate_deltas(alpm_handle_t *handle, alpm_list_t *deltas,
alpm_list_t **data)
{
- int errors = 0, ret = 0;
+ int errors = 0;
alpm_list_t *i;
alpm_trans_t *trans = handle->trans;
@@ -747,8 +757,7 @@ 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);
- ret = _alpm_test_checksum(filepath, d->delta_md5, ALPM_CSUM_MD5);
- if(ret != 0) {
+ if(_alpm_test_checksum(filepath, d->delta_md5, ALPM_CSUM_MD5)) {
prompt_to_delete(trans, filepath, ALPM_ERR_DLT_INVALID);
errors++;
*data = alpm_list_add(*data, strdup(d->delta));
@@ -759,13 +768,7 @@ static int validate_deltas(alpm_handle_t *handle, alpm_list_t *deltas,
handle->pm_errno = ALPM_ERR_DLT_INVALID;
return -1;
}
- EVENT(trans, ALPM_TRANS_EVT_DELTA_INTEGRITY_DONE, NULL, NULL);
-
- /* Use the deltas to generate the packages */
- EVENT(trans, ALPM_TRANS_EVT_DELTA_PATCHES_START, NULL, NULL);
- ret = apply_deltas(handle);
- EVENT(trans, ALPM_TRANS_EVT_DELTA_PATCHES_DONE, NULL, NULL);
- return ret;
+ return 0;
}
static int download_files(alpm_handle_t *handle, alpm_list_t **deltas)
@@ -909,6 +912,11 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
}
alpm_list_free(deltas);
+ /* Use the deltas to generate the packages */
+ if(apply_deltas(handle)) {
+ return -1;
+ }
+
/* get the total size of all packages so we can adjust the progress bar more
* realistically if there are small and huge packages involved */
current = total_bytes = 0;