mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-22 15:58:50 -05:00
more sanity checks: do not add or remove databases while a trasaction is running
This commit is contained in:
parent
316cd2b573
commit
656a887d35
@ -167,6 +167,8 @@ pmdb_t *alpm_db_register(char *treename)
|
||||
/* Sanity checks */
|
||||
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, NULL));
|
||||
ASSERT(treename != NULL && strlen(treename) != 0, RET_ERR(PM_ERR_WRONG_ARGS, NULL));
|
||||
/* Do not register a database if a transaction is on-going */
|
||||
ASSERT(handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, NULL));
|
||||
|
||||
if(strcmp(treename, "local") == 0) {
|
||||
if(handle->db_local != NULL) {
|
||||
@ -221,6 +223,8 @@ int alpm_db_unregister(pmdb_t *db)
|
||||
/* Sanity checks */
|
||||
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
|
||||
ASSERT(db != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
|
||||
/* Do not unregister a database if a transaction is on-going */
|
||||
ASSERT(handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, NULL));
|
||||
|
||||
if(db == handle->db_local) {
|
||||
db_close(handle->db_local);
|
||||
@ -267,6 +271,8 @@ int alpm_db_update(PM_DB *db, char *archive, char *ts)
|
||||
/* Sanity checks */
|
||||
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
|
||||
ASSERT(db != NULL && db != handle->db_local, RET_ERR(PM_ERR_WRONG_ARGS, -1));
|
||||
/* Do not update a database if a transaction is on-going */
|
||||
ASSERT(handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, NULL));
|
||||
|
||||
if(!pm_list_is_in(db, handle->dbs_sync)) {
|
||||
RET_ERR(PM_ERR_DB_NOT_FOUND, -1);
|
||||
|
Loading…
Reference in New Issue
Block a user