Prompt to delete invalid package

This commit is contained in:
morganamilo 2023-11-16 06:04:12 +00:00 committed by Allan McRae
parent 386125fc89
commit 62095d916b

View file

@ -1127,7 +1127,7 @@ static int load_packages(alpm_handle_t *handle, alpm_list_t **data,
{ {
size_t current = 0, current_bytes = 0; size_t current = 0, current_bytes = 0;
int errors = 0; int errors = 0;
alpm_list_t *i; alpm_list_t *i, *delete = NULL;
alpm_event_t event; alpm_event_t event;
/* load packages from disk now that they are known-valid */ /* load packages from disk now that they are known-valid */
@ -1150,6 +1150,7 @@ static int load_packages(alpm_handle_t *handle, alpm_list_t **data,
filepath = _alpm_filecache_find(handle, spkg->filename); filepath = _alpm_filecache_find(handle, spkg->filename);
if(!filepath) { if(!filepath) {
FREELIST(delete);
_alpm_log(handle, ALPM_LOG_ERROR, _alpm_log(handle, ALPM_LOG_ERROR,
_("%s: could not find package in cache\n"), spkg->name); _("%s: could not find package in cache\n"), spkg->name);
RET_ERR(handle, ALPM_ERR_PKG_NOT_FOUND, -1); RET_ERR(handle, ALPM_ERR_PKG_NOT_FOUND, -1);
@ -1170,7 +1171,7 @@ static int load_packages(alpm_handle_t *handle, alpm_list_t **data,
if(error != 0) { if(error != 0) {
errors++; errors++;
*data = alpm_list_add(*data, strdup(spkg->filename)); *data = alpm_list_add(*data, strdup(spkg->filename));
free(filepath); delete = alpm_list_add(delete, filepath);
_alpm_pkg_free(pkgfile); _alpm_pkg_free(pkgfile);
continue; continue;
} }
@ -1194,6 +1195,11 @@ static int load_packages(alpm_handle_t *handle, alpm_list_t **data,
EVENT(handle, &event); EVENT(handle, &event);
if(errors) { if(errors) {
for(i = delete; i; i = i->next) {
prompt_to_delete(handle, i->data, ALPM_ERR_PKG_INVALID);
}
FREELIST(delete);
if(handle->pm_errno == ALPM_ERR_OK) { if(handle->pm_errno == ALPM_ERR_OK) {
RET_ERR(handle, ALPM_ERR_PKG_INVALID, -1); RET_ERR(handle, ALPM_ERR_PKG_INVALID, -1);
} }