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>
This commit is contained in:
parent
16fd66f879
commit
062c391919
1 changed files with 19 additions and 11 deletions
|
@ -630,7 +630,7 @@ static int endswith(const char *filename, const char *extension)
|
||||||
static int apply_deltas(alpm_handle_t *handle)
|
static int apply_deltas(alpm_handle_t *handle)
|
||||||
{
|
{
|
||||||
alpm_list_t *i;
|
alpm_list_t *i;
|
||||||
int ret = 0;
|
int deltas_found = 0, ret = 0;
|
||||||
const char *cachedir = _alpm_filecache_setup(handle);
|
const char *cachedir = _alpm_filecache_setup(handle);
|
||||||
alpm_trans_t *trans = handle->trans;
|
alpm_trans_t *trans = handle->trans;
|
||||||
|
|
||||||
|
@ -643,6 +643,13 @@ static int apply_deltas(alpm_handle_t *handle)
|
||||||
continue;
|
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) {
|
for(dlts = delta_path; dlts; dlts = dlts->next) {
|
||||||
alpm_delta_t *d = dlts->data;
|
alpm_delta_t *d = dlts->data;
|
||||||
char *delta, *from, *to;
|
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;
|
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,
|
static int validate_deltas(alpm_handle_t *handle, alpm_list_t *deltas,
|
||||||
alpm_list_t **data)
|
alpm_list_t **data)
|
||||||
{
|
{
|
||||||
int errors = 0, ret = 0;
|
int errors = 0;
|
||||||
alpm_list_t *i;
|
alpm_list_t *i;
|
||||||
alpm_trans_t *trans = handle->trans;
|
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);
|
alpm_delta_t *d = alpm_list_getdata(i);
|
||||||
char *filepath = _alpm_filecache_find(handle, d->delta);
|
char *filepath = _alpm_filecache_find(handle, d->delta);
|
||||||
|
|
||||||
ret = _alpm_test_checksum(filepath, d->delta_md5, ALPM_CSUM_MD5);
|
if(_alpm_test_checksum(filepath, d->delta_md5, ALPM_CSUM_MD5)) {
|
||||||
if(ret != 0) {
|
|
||||||
prompt_to_delete(trans, filepath, ALPM_ERR_DLT_INVALID);
|
prompt_to_delete(trans, filepath, ALPM_ERR_DLT_INVALID);
|
||||||
errors++;
|
errors++;
|
||||||
*data = alpm_list_add(*data, strdup(d->delta));
|
*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;
|
handle->pm_errno = ALPM_ERR_DLT_INVALID;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
EVENT(trans, ALPM_TRANS_EVT_DELTA_INTEGRITY_DONE, NULL, NULL);
|
return 0;
|
||||||
|
|
||||||
/* 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int download_files(alpm_handle_t *handle, alpm_list_t **deltas)
|
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);
|
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
|
/* get the total size of all packages so we can adjust the progress bar more
|
||||||
* realistically if there are small and huge packages involved */
|
* realistically if there are small and huge packages involved */
|
||||||
current = total_bytes = 0;
|
current = total_bytes = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue