A bit of sanity checking in rpmtsRebuildDB()

- Don't permit rebuilddb on populated transaction as rebuild can
  and usually does change header instance numbering.
This commit is contained in:
Panu Matilainen 2010-12-03 15:31:01 +02:00
parent 4a3d7f2c73
commit 626e78429f
1 changed files with 15 additions and 8 deletions

View File

@ -125,14 +125,21 @@ int rpmtsSetDBMode(rpmts ts, int dbmode)
int rpmtsRebuildDB(rpmts ts)
{
int rc;
rpmlock lock = rpmtsAcquireLock(ts);
if (!lock) return -1;
if (!(ts->vsflags & RPMVSF_NOHDRCHK))
rc = rpmdbRebuild(ts->rootDir, ts, headerCheck);
else
rc = rpmdbRebuild(ts->rootDir, NULL, NULL);
rpmlockFree(lock);
int rc = -1;
rpmlock lock = NULL;
/* Cannot do this on a populated transaction set */
if (rpmtsNElements(ts) > 0)
return -1;
lock = rpmtsAcquireLock(ts);
if (lock) {
if (!(ts->vsflags & RPMVSF_NOHDRCHK))
rc = rpmdbRebuild(ts->rootDir, ts, headerCheck);
else
rc = rpmdbRebuild(ts->rootDir, NULL, NULL);
rpmlockFree(lock);
}
return rc;
}