1
0
mirror of https://github.com/moparisthebest/pacman synced 2025-01-08 12:28:00 -05:00

trans.c: create transaction prior to checking DB version

The addition of the DB version check introduces a lag time between the
lockfile creation and the transaction initialization. In cases where the
local DB is large enough and/or the user's disk is slow enough, this
time is significant enough that its possible for a user to send a SIGINT
and leave behind a db.lck file.

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dave Reisner 2011-05-14 12:54:03 -04:00 committed by Dan McGee
parent b14c5477e5
commit b9a2318bec

View File

@ -120,15 +120,6 @@ int SYMEXPORT alpm_trans_init(pmtransflag_t flags,
}
}
/* check database version */
db_version = _alpm_db_version(handle->db_local);
if(db_version < required_db_version) {
_alpm_log(PM_LOG_ERROR,
_("%s database version is too old\n"), handle->db_local->treename);
remove_lock(handle);
RET_ERR(PM_ERR_DB_VERSION, -1);
}
trans = _alpm_trans_new();
if(trans == NULL) {
RET_ERR(PM_ERR_MEMORY, -1);
@ -142,6 +133,16 @@ int SYMEXPORT alpm_trans_init(pmtransflag_t flags,
handle->trans = trans;
/* check database version */
db_version = _alpm_db_version(handle->db_local);
if(db_version < required_db_version) {
_alpm_log(PM_LOG_ERROR,
_("%s database version is too old\n"), handle->db_local->treename);
remove_lock(handle);
_alpm_trans_free(trans);
RET_ERR(PM_ERR_DB_VERSION, -1);
}
return(0);
}