mirror of
https://github.com/moparisthebest/pacman
synced 2025-02-28 09:21:53 -05:00
Improved error handling in add_loadtarget()
This commit is contained in:
parent
467b83aed4
commit
ba13bc8b7b
@ -68,24 +68,23 @@ int add_loadtarget(pmdb_t *db, pmtrans_t *trans, char *name)
|
||||
|
||||
/* no additional hyphens in version strings */
|
||||
if(strchr(info->version, '-') != strrchr(info->version, '-')) {
|
||||
FREEPKG(info);
|
||||
pm_errno = PM_ERR_INVALID_NAME;
|
||||
return(-1);
|
||||
goto error;
|
||||
}
|
||||
|
||||
dummy = db_get_pkgfromcache(db, info->name);
|
||||
/* only freshen this package if it is already installed and at a lesser version */
|
||||
if(trans->flags & PM_TRANS_FLAG_FRESHEN) {
|
||||
if(dummy == NULL || rpmvercmp(dummy->version, info->version) >= 0) {
|
||||
FREEPKG(info);
|
||||
PM_RET_ERR(PM_ERR_PKG_CANT_FRESH, -1);
|
||||
pm_errno = PM_ERR_PKG_CANT_FRESH;
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
/* only install this package if it is not already installed */
|
||||
if(trans->type != PM_TRANS_TYPE_UPGRADE) {
|
||||
if(dummy) {
|
||||
FREEPKG(info);
|
||||
PM_RET_ERR(PM_ERR_PKG_INSTALLED, -1);
|
||||
pm_errno = PM_ERR_PKG_INSTALLED;
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,6 +108,10 @@ int add_loadtarget(pmdb_t *db, pmtrans_t *trans, char *name)
|
||||
trans->packages = pm_list_add(trans->packages, info);
|
||||
|
||||
return(0);
|
||||
|
||||
error:
|
||||
FREEPKG(info);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int add_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user