mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-22 07:48:50 -05:00
alpm: Abort ASAP on failure in pre-transaction hooks
There is no need to run any/remaining pre-transaction hooks as soon as a failure has occured, which will lead to aborting the transaction. So if an error occured during the first phase (reading directories/parsing files), or as soon as a hook flagged abort_on_fail does fail, we stop processing them and return. (For post-transaction hooks, all hooks are run regardless since there's no aborting.) Signed-off-by: Olivier Brunel <jjk@jjacky.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
8454daa7fe
commit
eadf389607
@ -712,6 +712,10 @@ int _alpm_hook_run(alpm_handle_t *handle, alpm_hook_when_t when)
|
|||||||
closedir(d);
|
closedir(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(ret != 0 && when == ALPM_HOOK_PRE_TRANSACTION) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
hooks = alpm_list_msort(hooks, alpm_list_count(hooks),
|
hooks = alpm_list_msort(hooks, alpm_list_count(hooks),
|
||||||
(alpm_list_fn_cmp)_alpm_hook_cmp);
|
(alpm_list_fn_cmp)_alpm_hook_cmp);
|
||||||
|
|
||||||
@ -745,6 +749,10 @@ int _alpm_hook_run(alpm_handle_t *handle, alpm_hook_when_t when)
|
|||||||
|
|
||||||
hook_event.type = ALPM_EVENT_HOOK_RUN_DONE;
|
hook_event.type = ALPM_EVENT_HOOK_RUN_DONE;
|
||||||
EVENT(handle, &hook_event);
|
EVENT(handle, &hook_event);
|
||||||
|
|
||||||
|
if(ret != 0 && when == ALPM_HOOK_PRE_TRANSACTION) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
alpm_list_free(hooks_triggered);
|
alpm_list_free(hooks_triggered);
|
||||||
|
Loading…
Reference in New Issue
Block a user