Panu Matilainen f3f6be
commit 5ddb36d2739653ebe50dc39176a9ca43d0555676
Panu Matilainen f3f6be
Author: Panu Matilainen <pmatilai@redhat.com>
Panu Matilainen f3f6be
Date:   Fri Jan 21 13:43:12 2011 +0200
Panu Matilainen f3f6be
Panu Matilainen f3f6be
    Avoid automatic index generation on db rebuild
Panu Matilainen f3f6be
    - The rebuild walks through it all anyway, calling buildIndexes()
Panu Matilainen f3f6be
      while in middle of db rebuild ends up in first header added
Panu Matilainen f3f6be
      twice to indexes
Panu Matilainen f3f6be
Panu Matilainen f3f6be
diff --git a/lib/rpmdb.c b/lib/rpmdb.c
Panu Matilainen f3f6be
index 02aef4a..e58de35 100644
Panu Matilainen f3f6be
--- a/lib/rpmdb.c
Panu Matilainen f3f6be
+++ b/lib/rpmdb.c
Panu Matilainen f3f6be
@@ -157,6 +157,7 @@ static dbiIndex rpmdbOpenIndex(rpmdb db, rpmDbiTagVal rpmtag, int flags)
Panu Matilainen f3f6be
     } else {
Panu Matilainen f3f6be
 	db->_dbi[dbix] = dbi;
Panu Matilainen f3f6be
 	int verifyonly = (flags & RPMDB_FLAG_VERIFYONLY);
Panu Matilainen f3f6be
+	int rebuild = (db->db_flags & RPMDB_FLAG_REBUILD);
Panu Matilainen f3f6be
 	if (dbiType(dbi) == DBI_PRIMARY) {
Panu Matilainen f3f6be
 	    /* Allocate based on max header instance number + some reserve */
Panu Matilainen f3f6be
 	    if (!verifyonly && (db->db_checked == NULL)) {
Panu Matilainen f3f6be
@@ -170,7 +171,7 @@ static dbiIndex rpmdbOpenIndex(rpmdb db, rpmDbiTagVal rpmtag, int flags)
Panu Matilainen f3f6be
 		dbSetFSync(db->db_dbenv, 0);
Panu Matilainen f3f6be
 	    }
Panu Matilainen f3f6be
 	} else { /* secondary index */
Panu Matilainen f3f6be
-	    if (!verifyonly && (dbiFlags(dbi) & DBI_CREATED)) {
Panu Matilainen f3f6be
+	    if (!rebuild && !verifyonly && (dbiFlags(dbi) & DBI_CREATED)) {
Panu Matilainen f3f6be
 		rpmlog(RPMLOG_DEBUG, "index %s needs creating\n", dbiName(dbi));
Panu Matilainen f3f6be
 		db->db_buildindex++;
Panu Matilainen f3f6be
                 if (db->db_buildindex == 1) {